js splice方法可以用于删除对象数组吗或者替换对象数组中的元素?
1 回答

慕尼黑5688855
TA贡献1848条经验 获得超2个赞
var months = ['Jan', 'March', 'April', 'June']; months.splice(1, 0, 'Feb'); // inserts at 1st index position console.log(months); // expected output: Array ['Jan', 'Feb', 'March', 'April', 'June'] months.splice(4, 1, 'May'); // replaces 1 element at 4th index console.log(months); // expected output: Array ['Jan', 'Feb', 'March', 'April', 'May']
添加回答
举报
0/150
提交
取消