# lodash toSafeInteger

转换 value 为一个有限数字。

概要

_.toSafeInteger(value)

转换 value 为一个有限数字。

添加版本

4.12.0

参数

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

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

例子


_.toSafeInteger(3.2);
// => 3
 
_.toSafeInteger(Number.MIN_VALUE);
// => 0
 
_.toSafeInteger(Infinity);
// => 9007199254740991
 
_.toSafeInteger('3.2');
// => 3

Last Updated: 6/17/2023, 6:57:19 PM