Determine whether there are differences in multiple arrays

I use this data structure uniformly here

数据结构如下 数据源
const ObjArr = [["A", "B", "C"],["A", "B", "D"]]

Different in multidimensional array

//  数据源
const ObjArr = [["A", "B", "C"],["A", "B", "D"]]
//  代码如下
 ObjArr.map(item => {
   for(let i=0; i<item.length; i++) {
      for(let j=0; j<ObjArr.length; j++) {
        if (ObjArr[j][i] !== item[i]) {
          console.log(item[i], '这是不同数据')
        }
      }
    }
  })

Of course the data is extracted from the object at the beginning

// 从对象中提取出来变成一个数组,  当然这个match_txt是一个数组,
// 数组中第二个索引是对象
let ObjArr = []
match_txt.map(item => {
   ObjArr.push(Object.keys(item[0]))
 })

This is to judge whether the length of multiple arrays is the same

// 数据结构是和上面一样
const ObjArr = [["A", "B", "C"],["A", "B", "D"]]

for(let i=0; i<ObjArr.length; i++) {
   
   for(let j=1; j<ObjArr.length; j++) {

      if (ObjArr[i].length !== ObjArr[j].length && i !== j) {
        console.log(ObjArr[i], '这个不同')
      }
    }
  }

Guess you like

Origin blog.csdn.net/weixin_44953227/article/details/101022136