Javascript Interview Question, Guess the Output 5

preview_player
Показать описание
#shorts #shortsvideo #javascript #programming #programmer #developer #GIStudio #gto #trending #trend #trendingshorts

*******Output*******
Have you guessed foo = 1 or foo = 2?

It’s neither one of them. It will print undefined.

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.

var foo;
foo = 1;

function myFun(){

var foo; // var hoisted and initialized with undefined

foo = 2;
}

myFun();
Рекомендации по теме