1.比较两个数组(数组中是对象)是否全等:
let objArr = [{
nema: "123",
age: "19"
}, {
name: "234",
age: "22"
}];
let obj2Arr = [{
nema: "123",
age: "19"
}, {
name: "234",
age: "22"
}];
console.log(JSON.stringify(objArr) === JSON.stringify(obj2Arr)); // true
2.比较两个对象是否全等
let obj = {
name:"小名",
age:15
};
let obj2 = {
name:"小名",
age:15
}
console.log(JSON.stringify(obj) === JSON.stringify(obj2)); // true