@pengzhanbo/utils - v3.7.3
    Preparing search index...

    Function deepEqual

    • Deep equality two values, support array / object / date / set / map / regexp

      深度比较两个值是否相等,支持数组、对象、日期、集合、映射、正则表达式等类型值

      Parameters

      • v1: any

        The first value to compare. 第一个要比较的值

      • v2: any

        The second value to compare. 第二个要比较的值

      Returns boolean

      True if the values are deeply equal, false otherwise. 如果值深度相等则返回true,否则返回false

      This function uses an internal Map stack to handle circular references safely, preventing infinite recursion. NaN is considered equal to NaN (via Object.is), which differs from the default === behavior.

      此函数使用内部的 Map 栈来安全处理循环引用,防止无限递归。 NaN 被认为等于 NaN(通过 Object.is 判断),这与默认的 === 行为不同。 When comparing RegExp objects, only source and flags are compared; the lastIndex property is ignored. If you need to compare lastIndex, reset it manually before calling this function.

      比较正则表达式时,仅比较 sourceflagslastIndex 属性会被忽略。 如需比较 lastIndex,请在调用此函数前手动重置。

      deepEqual([1, 2, 3], [1, 2, 3]) // true
      deepEqual({ a: 1, b: 2 }, { a: 1, b: 2 }) // true
      deepEqual(new Date(), new Date()) // true
      deepEqual(new Set([1, 2, 3]), new Set([1, 2, 3])) // true
      deepEqual(new Map([['a', 1], ['b', 2]]), new Map([['a', 1], ['b', 2]])) // true
      deepEqual(new RegExp('a'), new RegExp('a')) // true
      deepEqual('hello', 'hello') // true
      deepEqual('hello', 'world') // false
      deepEqual(null, null) // true
      deepEqual(undefined, undefined) // true
      deepEqual(NaN, NaN) // true