- 1
Var vs function.
What is the difference between var x = true (result is boolean) and var x = function() { return true }. (Returns boolean..?) Both variable and function I can invoke on any time. My mind now is overheat. Var x and var x() or function x() - Where this ones are used?
1 Respuesta
+ 7
Differences between Declarations and Expressions. Similar to the var statement, function declarations are hoisted to the top of other code. Function expressions aren't hoisted, which allows them to retain a copy of the local variables from the scope where they were defined.
https://www.sitepoint.com/function-expressions-vs-declarations/