Function toLength

  • Converts value to an integer suitable for use as the length of an array-like object.

    Note: This method is based on ToLength.

    Parameters

    • value: number

      The value to convert.

    Returns number

    Returns the converted integer.

    5.13.0

    toLength(3.2)
    // => 3

    toLength(Number.MIN_VALUE)
    // => 0

    toLength(Infinity)
    // => 4294967295

    toLength('3.2')
    // => 3
  • Converts value to an integer suitable for use as the length of an array-like object.

    Note: This method is based on ToLength.

    Parameters

    • value: string

      The value to convert.

    Returns number

    Returns the converted integer.

    5.13.0

    toLength(3.2)
    // => 3

    toLength(Number.MIN_VALUE)
    // => 0

    toLength(Infinity)
    // => 4294967295

    toLength('3.2')
    // => 3