function permutation (list, n) {
var results = []
function _perm (list, n, res, start) {
if (res.length === n) {
return results.push(res.join(','))
}
if (start === list.length) { return }
_perm(list, n, res.slice(), start + 1)
res.push(list[start])
_perm(list, n, res, start + 1)
}
_perm(list, n, [], 0)
return results
}
const arr = [1,2,3,4,5,6,7,8,9,10]
permutation(arr, 5)