js中对于数组的操作很常见,下面记录一下js向数组添加元素的方法。
let myArray=[11,22,33];
console.log('原数组:',myArray);
myArray.push(44,55);
console.log('用push在数组后面插入元素:',myArray);
myArray.unshift(66,77);
console.log('用unshift在数组前面插入元素:',myArray);
myArray.splice(2,0,'肾虚少年');
console.log('用splice在数组指定位置插入元素:',myArray);


![[手游] 三网H5小游戏【少年仙路】WIN系服务端+Linux手工服务端+详细搭建教程](https://cdn.jxasp.com:9143/image/20260615/136BC33AA47EB0D84E878835A8B38FDB.png)

















