Skip to content

Instantly share code, notes, and snippets.

@HugoDF
Last active October 13, 2016 19:12
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/379f1ea019376ee3aae4635c59872085 to your computer and use it in GitHub Desktop.
Save HugoDF/379f1ea019376ee3aae4635c59872085 to your computer and use it in GitHub Desktop.
ES6 join implementation using recursion and destructuring
function join([ head, ...tail ], separator = ',') {
if (head === undefined && !tail.length) return '';
return tail.length ? head + separator + join(tail, separator) : head;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment