Created
September 17, 2015 12:51
-
-
Save dnasca/fa0772cbedd4b2aecfa4 to your computer and use it in GitHub Desktop.
ES2015 Fat Arrow Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let arr = [4, 9, 14]; | |
| // the old way | |
| let newArr = arr.map(function (value) { | |
| return value + 1; | |
| }); | |
| // the new way - ES2015 (3 examples of the same function, each better than the one before it) | |
| let newArr = arr.map( (value) => { return value +1; }); | |
| arr.map( value => { return value + 1; }); | |
| arr.map( value => value + 1 ) | |
| console.log(newArr); | |
| console.log(newArr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment