Saturday, December 1, 2012

Javascript hoisting and scoping

http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting

var a = 1;
function b() {
a = 10;
return;
function a() {}
}
b();
alert(a);

function a() {} is actually defined first and therefore the assignment to a = 10 is ignored

No comments:

Post a Comment