Sunday, February 17, 2019

local variables - Does javascript implement lexical scoping?

Why does this return 2 instead of 1? Seems the second "var" is silently ignored.



function foo()
{
var local = 1;
{
var local = 2;

}
return local;
}
foo()
/*
2
*/

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...