Last active
October 13, 2016 19:12
-
-
Save HugoDF/379f1ea019376ee3aae4635c59872085 to your computer and use it in GitHub Desktop.
ES6 join implementation using recursion and destructuring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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