猿问

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

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


宝慕林4294392
浏览 489回答 1
1回答

慕尼黑5688855

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']
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答