SOURCE

let numbrsCopy = Array.of(1,2,3,4,5,6)
console.log(numbrsCopy)
numbrsCopy.fill(0)//数组所有值填充为0
console.log(numbrsCopy)
numbrsCopy.fill(1,0,1);//填充1从位置零到位置一,不包括位置一
console.log(numbrsCopy);
numbrsCopy.fill(2,1,3);//填充2从位置一到位置三,不包括位置三
console.log(numbrsCopy);
let ones = Array(6).fill(8);//创建一个长度为6值都为8的数组

console.log("=======")
let copyArray = [1,2,3,4,5,6];
//下面相当于copyArray.copyWithin(0,3,-1);
copyArray.copyWithin(0,3);//将位置三到结尾的元素(4,5,6)复制到位置零
console.log(copyArray);// 4,5,6,4,5,6
let copyArray2 = [1,2,3,4,5,6,7];
copyArray2.copyWithin(1,4,6);//从位置四到位置六的元素(5,6)复制到位置一,头尾不包尾
console.log(copyArray2);// 1,5,6,4,5,6,7


console 命令行工具 X clear

                    
>
console