Skip to content

Instantly share code, notes, and snippets.

@why-jay
Last active August 29, 2015 14:13
Show Gist options
  • Save why-jay/2667836a895db184e1b2 to your computer and use it in GitHub Desktop.
Save why-jay/2667836a895db184e1b2 to your computer and use it in GitHub Desktop.
// immutable version
const map = arr =>
arr.reduce((prev, cur) => prev.concat(cur), []);
// mutable version
const map = arr =>
arr.reduce((prev, cur) => {
prev.push(cur);
return prev;
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment