Functions
function test(){ // Declaration of a function
console.log(1+2);
};
// We can assign a function with no name to a variable
test = function(){ // This is known as an anonymous function
console.log(1+2);
};
test = function(){ console.log(1+2); }; // Can also be declared in a single line
test() // This calls the function and executes its content, prints 3test2() // Called before declaration, prints 4
function test2(){ // Declaration of a function after its call
console.log(2+2);
};Arrow Functions
Last updated