Using Number.MAX_SAFE_INTEGER vs Using static 2147483647 vs Using private 2147483647

Edit on GitHub

Is Number.MAX_SAFE_INTEGER faster than getting a static number

Setup

Number.MAX_SAFE_INTEGER vs 2147483647

Tests

  • Using Number.MAX_SAFE_INTEGER

    a = [{}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
    a.sort((b)) => Number.MAX_SAFE_INTEGER)
  • Using static 2147483647

    a = [{}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
    s = 2147483647;
    a.sort((b)) => s)
  • Using private 2147483647

    a = [{}, {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
    a.sort((b)) => 2147483647)