Reference int()

int()

Converts a Boolean, String, or decimal Number to an integer.

int() converts values to integers. Integers are positive or negative numbers without decimals. If the original value has decimals, as in -34.56, they're removed to produce an integer such as -34.

The parameter, n, is the value to convert. If n is a Boolean, as in int(false) or int(true), then the number 0 (false) or 1 (true) will be returned. If n is a string or number, as in int('45') or int(67.89), then an integer will be returned. If an array is passed, as in int([12.34, 56.78]), then an array of integers will be returned.

Note: If a value can't be converted to a number, as in int('giraffe'), then the value NaN (not a number) will be returned.

Examples

Syntax

int(n)
int(ns)

Parameters

n
String|Boolean|Number:

value to convert.

ns
Array:

values to convert.

Returns

Number: converted number.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/conversion.js and open a pull request!

Related References