Skip to content

Instantly share code, notes, and snippets.

@chriswrightdesign
Last active June 23, 2017 05:27
Show Gist options
  • Save chriswrightdesign/f1bd6928023582ac4220f0476d4cc3fb to your computer and use it in GitHub Desktop.
Save chriswrightdesign/f1bd6928023582ac4220f0476d4cc3fb to your computer and use it in GitHub Desktop.
Mapping example
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