Skip to content

Instantly share code, notes, and snippets.

@MACSkeptic
Created July 29, 2013 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MACSkeptic/6103359 to your computer and use it in GitHub Desktop.
Save MACSkeptic/6103359 to your computer and use it in GitHub Desktop.
callback is invoked only for indexes of the array which have assigned values (from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
[1, 2].map(function (x) { return x; }) // -> [1, 2]
[1,, 2].map(function (x) { return x; }) // -> [1, undefined × 1, 2]
[1, 2].map(function () { return 'constant'; }) // -> ["constant", "constant"]
[1,, 2].map(function () { return 'constant'; }) // -> ["constant", undefined × 1, "constant"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment