Javascript Quiz: How well do you know Variables in Javascript #programming #javascript #coding #quiz

preview_player
Показать описание
Are you ready for another code challenge? Join me in this video as you test your coding knowledge with the simple quiz questions.

Don't forget to make your guess in the comments below.

-------------------------------------------------------------------------------------------

🔔Like and subscribe for more videos. 🔔

Connect me on linkedin :
------------------------------------------------------------------------------------------

Answer OPTION: D) ReferenceError

Explanation:
The code defines a global variable x with an initial value of 10.

Inside the foo function, a local constant x is defined with a value of 20.

Hence, a ReferenceError is thrown, indicating that the variable x is not yet defined.

Therefore, the output will be a ReferenceError.
Рекомендации по теме
Комментарии
Автор

Option D. Before code is executed, js hoists const x that is inside the foo fn, it is hoisted into a deadzone (or shadow realm as I call it). When console log searches up, it finds that x exists inside the fn but it has not been initialized

perspectiva-psicologica