Skip to content

Instantly share code, notes, and snippets.

@HugoDF
Last active October 11, 2016 23:04
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 HugoDF/0e2493e0edf7e6087a7518a88ea78f5b to your computer and use it in GitHub Desktop.
Save HugoDF/0e2493e0edf7e6087a7518a88ea78f5b to your computer and use it in GitHub Desktop.
ES6 map implementation using arrow function, recursion and destructuring
var map = ([ head, ... tail ], fn) =>
( (head !== undefined && tail.length) ? ( tail.length ? [ fn(head), ...(map(tail, fn)) ] : [ fn(head) ] ) : []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment