给定一个数组, 长度为 n, 获取长度为3,数组元素的子序列
const arr = [1, 2, 3, 4, 5];
const res = [];
const len = arr.length;
for (let i = 0; i < len; i++) {
for (let j = i + 1; j < len; j++) {
for (let k = j + 1; k < len; k++) {
res.push([arr[i], arr[j], arr[k]]);
}
}
}
console.log(res);