toInteger source npm

_.toInteger(value)

Converts value to an integer.

Note: This function is loosely based on ToInteger.

Arguments

  1. value (*)

    The value to convert.

Returns (number)

Returns the converted integer.

Example

_.toInteger(3);
// => 3

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

_.toInteger(Infinity);
// => 1.7976931348623157e+308

_.toInteger('3');
// => 3