javascript 判断两个对象是否相等
程序员文章站
2022-06-10 20:29:25
...
function isObjectValueEqual(a, b) {
var aProps = Object.getOwnPropertyNames(a);
var bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) {
return false;
}
for (var i = 0; i < aProps.length; i++) {
var propName = aProps[i];
if (a[propName] !== b[propName]) {
return false;
}
}
return true;
}
转载于:https://www.jianshu.com/p/2fc8e671b2e7
下一篇: 测试数据