Converts `value` to an integer. **Note:** This method is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
toInteger(3.2)
// => 3
toInteger(Number.MIN_VALUE)
// => 0
toInteger(Infinity)
// => 1.7976931348623157e+308
toInteger('3.2')
// => 3
| Name | Type | Attribute | Description |
|---|---|---|---|
| value | The value to convert. |
{
"comment": "/**\r\n * Converts `value` to an integer.\r\n *\r\n * **Note:** This method is loosely based on\r\n * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).\r\n *\r\n * @since 4.0.0\r\n * @category Lang\r\n * @param {*} value The value to convert.\r\n * @returns {number} Returns the converted integer.\r\n * @see isInteger, isNumber, toNumber\r\n * @example\r\n *\r\n * toInteger(3.2)\r\n * // => 3\r\n *\r\n * toInteger(Number.MIN_VALUE)\r\n * // => 0\r\n *\r\n * toInteger(Infinity)\r\n * // => 1.7976931348623157e+308\r\n *\r\n * toInteger('3.2')\r\n * // => 3\r\n */",
"meta": {
"range": [
588,
762
],
"filename": "toInteger.js",
"lineno": 28,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100009886",
"name": "toInteger",
"type": "FunctionDeclaration",
"paramnames": [
"value"
]
},
"vars": {
"result": "toInteger~result",
"remainder": "toInteger~remainder"
}
},
"description": "Converts `value` to an integer.\r\r**Note:** This method is loosely based on\r[`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).",
"since": "4.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Lang",
"value": "Lang"
}
],
"params": [
{
"type": {
"names": [
"*"
]
},
"description": "The value to convert.",
"name": "value"
}
],
"returns": [
{
"type": {
"names": [
"number"
]
},
"description": "Returns the converted integer."
}
],
"see": [
"isInteger, isNumber, toNumber"
],
"examples": [
"toInteger(3.2)\r// => 3\r\rtoInteger(Number.MIN_VALUE)\r// => 0\r\rtoInteger(Infinity)\r// => 1.7976931348623157e+308\r\rtoInteger('3.2')\r// => 3"
],
"name": "toInteger",
"longname": "toInteger",
"kind": "function",
"scope": "global",
"___id": "T000002R000907",
"___s": true,
"filepath": "toInteger.js"
}