Saturday, 15 May 2010

javascript - does this variable get hoisted no matter what? -


What is the code inside the false block, even if var foo is hoisted on top of the stack Can not be executed at any time?

  function foo () {if (false) {var foo = 'bar'; // Will it never be executed, even if it is hoisted? }}   

I see that this is and it's just confused ... I did not expect that it would be wrapped in false cases.

Yes; The code is hosting before the code runs, so if statement comes out or not true or false is not yet known.

No comments:

Post a Comment