Last active
June 23, 2017 05:27
-
-
Save chriswrightdesign/f1bd6928023582ac4220f0476d4cc3fb to your computer and use it in GitHub Desktop.
Mapping example
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
const animals = ['dog', 'cat', 'bird', 'giraffe']; | |
// es5 | |
animals.map(function(currentValue, index, array) { | |
return 'super ' + currentValue; | |
}); | |
//es6 | |
animals.map((currentValue, index, array) => `super ${currentValue}`); | |
// result: ['super dog', 'super cat', 'super bird']; | |
/* | |
As it maps over the values, currentValue is equal to 'dog', then 'cat', then 'bird' etc | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment