Logos DX
    Preparing search index...

    Function hasSameConstructor

    • Checks if both values have the same constructor.

      Compares the constructor property of two values to determine if they are instances of the same class or type.

      Parameters

      • value: unknown

        first value to compare

      • compare: unknown

        second value to compare

      Returns boolean

      true if both values have the same constructor

      hasSameConstructor([], [1, 2, 3]) // true (both Arrays)
      hasSameConstructor({}, { a: 1 }) // true (both Objects)
      hasSameConstructor([], {}) // false (Array vs Object)
      hasSameConstructor(new Date(), new Date()) // true (both Dates)
      hasSameConstructor('string', 42) // false (String vs Number)