I came up with a “javascript” of JavaScript, and I didn't understand how this piece of code really works:
var a = 1; function b() { a = 10; return; function a() {} } b(); alert(a);
I know that a function declaration like ( function a() {} ) will be raised at the top of region b , but should not override the value of a (since function declarations override variable declarations, but not initialization variables), so I expected that the warning value will be 10 instead of 1!
javascript hoisting
morfioce Mar 09 '13 at 13:22 2013-03-09 13:22
source share