输入两个带判断对象,输出所有value不同的key
const findDiffKey = function (obj1, obj2) {
const arr = []
for (const key in obj1) {
if (obj1.hasOwnProperty(key) && obj2.hasOwnProperty(key)) {
if (obj1[key] === obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
arr.push({key: key, value: obj1[key], type: 'obj'})
} else if (obj1[key] !== obj2[key] && JSON.stringify(obj1[key]) !== JSON.stringify(obj2[key])) {
arr.push({key: key, value: obj1[key]})
}
}
}
return arr
}