Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 19, 2014 14:13
Show Gist options
  • Save shaunwallace/eed7b0834ff3457b0483 to your computer and use it in GitHub Desktop.
Save shaunwallace/eed7b0834ff3457b0483 to your computer and use it in GitHub Desktop.
Array.prototype.forEach()
function double(element, index, array) {
console.log('elem['+ index + '] ', element * 2);
}
[1,2,3,4,5].foEach(double); // returns elem[0] 2 elem[1] 4 elem[2] 6 elem[3] 8 elem[4] 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment