toSafeInteger

Lang
since 4.0.0

Arguments

  • * The value to convert.

Returns

number the converted integer.

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

Example of Lodash _.toSafeInteger

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

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

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

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