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.

    Since

    5.13.0

    Example

    toLength(3.2)
    // => 3

    toLength(Number.MIN_VALUE)
    // => 0

    toLength(Infinity)
    // => 4294967295

    toLength('3.2')
    // => 3
  • Parameters

    • value: string

    Returns number