Library API
    Preparing search index...

    Function compare

    • Performs a three-way comparison between two numbers or two bigints.

      Parameters

      • a: number

        First numeric or bigint value

      • b: number

        Second numeric or bigint value

      Returns -1 | 0 | 1

      -1 if a < b, 0 if a === b, or 1 if a > b

      If either value is not a number/bigint or if a and b have mismatched types

      If either numeric argument is NaN

      compare(1, 2);   // -1
      compare(5n, 5n); // 0
      compare(9, 4); // 1
    • Performs a three-way comparison between two numbers or two bigints.

      Parameters

      • a: bigint

        First numeric or bigint value

      • b: bigint

        Second numeric or bigint value

      Returns -1 | 0 | 1

      -1 if a < b, 0 if a === b, or 1 if a > b

      If either value is not a number/bigint or if a and b have mismatched types

      If either numeric argument is NaN

      compare(1, 2);   // -1
      compare(5n, 5n); // 0
      compare(9, 4); // 1