let arr = [1, 2, 3, 4];
(arr)
[1, 2, 3, 4, 12, 13, 14, 23, 24, 34]
let arr = [1, 2, 3, 4];
(arr)
[1, 2, 3, 4, 12, 13, 14, 23, 24, 34]
var newArr = [];
for(var i=0;i<arr.length;iPP){
newArr.push(arr[i]);
for(var x=i+1;x<arr.length;xPP){
newArr.push(arr[i]+''+arr[x]);
}
}
var arr = [1, 2, 3, 4];
var i = [...arr];
i.forEach(value => {
arr.shift();
arr.forEach(v => {
if (value != v) {
i.push(Number('' + value + v));
}
})
}) //i [1, 2, 3, 4, 12, 13, 14, 23, 24, 34]
Previous: How does js reverse escape the slash?