Last active
December 1, 2015 18:38
-
-
Save nilz3ro/24f10319d3552d33e576 to your computer and use it in GitHub Desktop.
es6 recursion
This file contains 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
'use strict'; | |
const flatten = (...args) => { | |
let [head, ...tail] = args; | |
return head === undefined | |
? [] | |
: ( Array.isArray(head) ? [...flatten(...head), ...flatten(...tail)] : [head, ...flatten(...tail)] ) | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment