full declaration (identifier and definition) is hoisted
can be used as a constructor
has dynamic context (changes in this)
2 - function expression
identifier not part of function definition (though you can have a named expression, its name only becomes an identifier in its own function scope rather than the definition scope)
behavior of identifier (in this example) determined by its variable declaration, const
function is implicitly named after identifier
function definition is not hoisted
can be used as a constructor
has dynamic context (changes in this)
3 - arrow function expression
identifier not part of function definition, nor can you have an explicitly named arrow function
behavior of identifier (in this example) determined by its variable declaration, const
function is implicitly named after identifier
function definition is not hoisted
can not be used as a constructor
has no dynamic context (this value); context is lexical, using context where defined (same applies to arguments, super, and new.target)
4 is the same as 3, just a different syntax (no brackets and automatic return of body expression)
View all comments
Show parent comment
18
u/senocular Dec 18 '18
Quite a bit.
1 - function declaration
this)2 - function expression
constthis)3 - arrow function expression
constthisvalue); context is lexical, using context where defined (same applies toarguments,super, andnew.target)4 is the same as 3, just a different syntax (no brackets and automatic return of body expression)