Function expressions and arrows
// function declaration
function sayHi() {
alert( "Hello" );
}
// function expression
let sayHi = function() {
alert( "Hello" );
};
function sayHi() { // (1) create
alert( "Hello" );
}
let func = sayHi; // (2) copy
func(); // Hello // (3) run the copy (it works)!
sayHi(); // Hello // this still works too (why wouldn't it)Callback functions
Function Expression vs Function Declaration
Arrow functions
Last updated