What is an arrow function?
JavaScript
Arrow Functions
An arrow function is a compact alternative to traditional function.
- they are more concise than the tranditional functions
- they manage 'this' keyword differently
Traditional Function
// Traditional Functionfunction multiplyBy2(input) { return input * 2;}Arrow Function
// Remove the word "function" and place arrow between the argument and opening body bracketconst multiplyBy2 = (input) => { return input * 2;};// Remove the body brackets and word "return" -- the return is impliedconst multiplyBy2 = (input) => input * 2;// Remove the argument parenthesisconst multiplyBy2 = (input) => input * 2;const output = multiplayBy2(3); // 6