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
JAVASCRIPT
1// Traditional Function2function multiplyBy2(input) {3 return input * 2;4}
Arrow Function
JAVASCRIPT
1// Remove the word "function" and place arrow between the argument and opening body bracket2const multiplyBy2 = (input) => {3 return input * 2;4};
JAVASCRIPT
1// Remove the body brackets and word "return" -- the return is implied2const multiplyBy2 = (input) => input * 2;
JAVASCRIPT
1// Remove the argument parenthesis2const multiplyBy2 = (input) => input * 2;
JAVASCRIPT
1const output = multiplayBy2(3); // 6