/**
*
* 判断对象是否完全一致
* @param {*} a
* @param {*} b
* @return {*}
*/
const isEqual = function (a, b) {
if (a === b) {
return a !== 0 || 1 / a === 1 / b;
};
if (a == null || b == null) {
return a === b;
};
var A = Object.prototype.toString.call(a);
var B = Object.prototype.toString.call(b);
if (A !== B) {
return false;
};
switch (A) {
case '[object RegExp]':
case '[object String]':
return '' + a === '' + b;
case '[object Number]':
if (+a !== +a) {
return +b !== +b;
};
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
return +a === +b;
};
if (A == '[object Object]') {
if (JSON.stringify(a) != JSON.stringify(b)) {
return false;
};
return true;
};
if (A == '[object Array]') {
if (a.toString() == b.toString()) {
return true;
}
return false;
};
};
01-10
1444
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-18
2812
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)