_.toSafeInteger

_.toSafeInteger(value)

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

Since

4.0.0

Arguments

  1. value (*): The value to convert.

Returns

(number): Returns the converted integer.

Example

1
2
3
4
5
6
7
8
9
10
11
_.toSafeInteger(3.2);
// => 3
  
_.toSafeInteger(Number.MIN_VALUE);
// => 0
  
_.toSafeInteger(Infinity);
// => 9007199254740991
  
_.toSafeInteger('3.2');
// => 3
doc_Lodash
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.