// var temp;
// var count;
// for (var i = 0; i < that.mousePoint.length; i++) { // 第一次遍历数组,确保数组里的子数组都能被检测
// temp = that.mousePoint[i]; // 存储被检测的当前子数组
// for (var k = 0; k < that.mousePoint.length; k++) {
// if (k != i && that.mousePoint[k].length == temp.length) { // 第二次遍历数组,检测除了被检测数组本身以及两者长度不一样的子数组
// count = 0; // 初始化
// for (var j = 0; j < that.mousePoint[k].length; j++) { // 遍历检测的子数组
// if (that.mousePoint[k][j] == temp[j]) {
// count++; // 记录检测子数组与被检测子数组中的元素重复次数
// }
// }
// if (count == temp.length) { // 如果次数与被检测子数组的长度相等,代表两者重复
// that.mousePoint.splice(k,1); // 删除该重复元素
// k--; // 数组长度变化,K需要减一回到当前位置
// }
// }
// }
// console.log("mousePoint "+that.mousePoint);
// that.mouseStr.push(that.mousePoint);
// console.log("mouseStr "+that.mouseStr);
// that.mouseData=[];
// that.mousePoint=[];
// console.log(1111);
// }
JS二维数组去重
最新推荐文章于 2025-04-17 23:08:35 发布