Skip to content

Instantly share code, notes, and snippets.

@nilz3ro
Last active December 1, 2015 18:38
Show Gist options
  • Save nilz3ro/24f10319d3552d33e576 to your computer and use it in GitHub Desktop.
Save nilz3ro/24f10319d3552d33e576 to your computer and use it in GitHub Desktop.
es6 recursion
'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