xuanbingbingo
 
const equals = (a, b) => {
  if (a === b) return true;
  if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();
  if (!a || !b || (typeof a !== \'object\' && typeof b !== \'object\')) return a === b;
  if (a.prototype !== b.prototype) return false;
  let keys = Object.keys(a);
  if (keys.length !== Object.keys(b).length) return false;
  return keys.every(k => equals(a[k], b[k]));
};

  

equals({ a: [2, { e: 3 }], b: [4], c: \'foo\' }, { a: [2, { e: 3 }], b: [4], c: \'foo\' }); // true

  原文链接:https://juejin.im/post/5da1a04ae51d45783d6122bf

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-11-20
  • 2021-10-16
  • 2021-12-07
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案