Skip to content

toLength

js
_.toLength(value)

value 转换为适合用作类似数组的对象长度的整数。

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

注意:此方法基于 ToLength

¥Note: This method is based on ToLength.

新增于

¥Since

4.0.0

参数

¥Arguments

  1. value (*):要转换的值。

    ¥value ()*: The value to convert.

返回

¥Returns

(数值):返回转换后的整数。

¥(number): Returns the converted integer.

示例

¥Example

js
_.toLength(3.2);
// => 3

_.toLength(Number.MIN_VALUE);
// => 0

_.toLength(Infinity);
// => 4294967295

_.toLength('3.2');
// => 3

Lodash v4.17 中文网 - 粤ICP备13048890号