splice的使用

 let myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
  // let newArr = myFish.splice(1,2) //删 :如果没删除则返回空数组
  // let newArr = myFish.splice(0,0,'mandarin', 'sturgeon') //增
  myFish.splice(2,2,'王五','赵六') //改
  console.log(myFish);  
posted on 2024-12-22 11:07  Steven_YF  阅读(19)  评论(0)    收藏  举报