4 ms·
No, with or without the var doesn't change the fact that it is still a variable declaration. Without the "var" keyword, you just created a global variable rath
by LunaSea 13y ago
No, with or without the var doesn't change the fact that it is still a variable declaration.
Without the "var" keyword, you just created a global variable rather than one restricted to your local scope.
- jaredmcateer 13y agoThe function declaration is still restricted to the scope it's within. The problem is that the function declaration does some additional hoisting magic nothing else gets. If you declare a variable in the middle of a function the variable name gets hoisted but the value does not. If you declare a function in the middle of another function the name gets hoisted but so does the value. This can lead to some additional quirkiness, which is why it's recommended to use the expression assigned ot a variable, to maintain consistency.
- sarink 13y ago+99999