function isObject(obj) { return typeof obj === 'object' && obj !== null } function isEqual(obj1, obj2) { if (!isObject(obj1) || !isObject(obj2)) { return obj1 === obj2; } if (obj1 === obj2) { return true; } let obj1keys = Object.keys(obj1); let obj2keys = Object.keys(obj2); if (obj1keys.length !== obj2keys.length) { return false; } for(let k in obj1) { const res = isEqual(obj1[k], obj2[k]); if (!res) { return false } } return true; }
标签:obj1,obj2,return,isObject,js,let,obj,手写,比较 From: https://www.cnblogs.com/bruce-gou/p/17415931.html