var arr = [[1,"ad"],[21,"qwe"]];
for(var i=0; i<arr.length; i++) {
if (arr[i+1][1] == arr[i][1]) {
arr.splice(i, 1);
}
}VM294:4 Uncaught TypeError: Cannot read property '1' of undefined
at <anonymous>:4:19
2 回答
FSYu
TA贡献152条经验 获得超59个赞
var arr = [ { 1: "ad" }, { 1: "ad", 21: "qwe" } ]; for (var i = 0; i < arr.length; i++) { if (arr[i + 1][1] == arr[i][1]) { arr.splice(i, 1); } }
不好意思,没太懂你的意思,你是想要这样???
添加回答
举报
0/150
提交
取消