I have an array of n different elements in javascript, I know there are n! possible ways to order these elements. I want to know what\'s the most effective (fastest) algorit
It is just for fun - my recursive solve in one string
const perm = a => a.length ? a.reduce((r, v, i) => [ ...r, ...perm([ ...a.slice(0, i), ...a.slice(i + 1) ]).map(x => [ v, ...x ])], []) : [[]]