Skip to content

Instantly share code, notes, and snippets.

@granmoe
Last active April 16, 2018 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granmoe/dfca22636b08a72e8426fd7e1c795056 to your computer and use it in GitHub Desktop.
Save granmoe/dfca22636b08a72e8426fd7e1c795056 to your computer and use it in GitHub Desktop.
[1, 2, 3].map(x => x * 2)
// is equivalent to
reduce((accum, current) => [...accum, current * 2], [])([1, 2, 3])
[1, 2, 3].filter(x => x > 2)
// is equivalent to
reduce((accum, current) => current > 2 ? [...accum, current] : accum, [])([1, 2, 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment