January 2020
Intermediate to advanced
548 pages
13h 36m
English
Function declarations are a type of hoisted declaration. A hoisted declaration is one that will, at runtime, be effectively hoisted up the top of its execution context, meaning that it will be immediately accessible to preceding lines of code (seemingly before it's declared):
hoistedDeclaration(); // => Does not throw an error...function hoistedDeclaration() {}
This, of course, is not possible with a function expression that's been assigned to a variable:
regularFunctionExpression(); // => Uncaught ReferenceError: // => Cannot access 'regularFunctionExpression' before initializationconst regularFunctionExpression = function() {};
The hoisted behavior of function declarations can create unexpected results, so it is typically ...
Read now
Unlock full access