The following will break, telling myFunc is not defined. myFunc(); const myFunc = function(){ ... };
The following one won't trigger error.
myFunc(); function myFunc() { ...}
The first one is called "function expression", the second one is called "function declaration". Understanding the difference teach a lot about how js is interpretedby the runtime.
1
u/jun-thong May 29 '19
The following will break, telling myFunc is not defined.
myFunc();const myFunc = function(){ ... };The following one won't trigger error.
myFunc();function myFunc() { ...}The first one is called "function expression", the second one is called "function declaration". Understanding the difference teach a lot about how js is interpretedby the runtime.