Skip to content

toSafeInteger ​

js
_.toSafeInteger(value)

将 value 转换为安全整数。可以比较并正确表示安全整数。

¥Converts value to a safe integer. A safe integer can be compared and represented correctly.

新增于 ​

¥Since

4.0.0

参数 ​

¥Arguments

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

    ¥value ()*: The value to convert.

返回 ​

¥Returns

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

¥(number): Returns the converted integer.

示例 ​

¥Example

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

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

_.toSafeInteger(Infinity);
// => 9007199254740991

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

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