第一次forEach循环,index是0,item是1 ,arr是[1,1,2], if条件成立,使用splice最终的arr是【1,2】 第二次循环,index是1,item是2,arr是[1,2], if条件不成立,使用splice没法删除了第二个重复的1; 缘由是使用splice容易使数组的index乱序。。。数组
正确作法: 对象
应用到对象上: blog