Converts `value` to an integer suitable for use as the length of an array-like object. **Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
toLength(3.2)
// => 3
toLength(Number.MIN_VALUE)
// => 0
toLength(Infinity)
// => 4294967295
toLength('3.2')
// => 3
Name | Type | Attribute | Description |
---|---|---|---|
value | The value to convert. |
{ "comment": "/**\r\n * Converts `value` to an integer suitable for use as the length of an\r\n * array-like object.\r\n *\r\n * **Note:** This method is based on\r\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\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 * @example\r\n *\r\n * toLength(3.2)\r\n * // => 3\r\n *\r\n * toLength(Number.MIN_VALUE)\r\n * // => 0\r\n *\r\n * toLength(Infinity)\r\n * // => 4294967295\r\n *\r\n * toLength('3.2')\r\n * // => 3\r\n */", "meta": { "range": [ 691, 908 ], "filename": "toLength.js", "lineno": 31, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100009925", "name": "toLength", "type": "FunctionDeclaration", "paramnames": [ "value" ] }, "vars": { "value": "toLength~value" } }, "description": "Converts `value` to an integer suitable for use as the length of an\rarray-like object.\r\r**Note:** This method is based on\r[`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).", "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." } ], "examples": [ "toLength(3.2)\r// => 3\r\rtoLength(Number.MIN_VALUE)\r// => 0\r\rtoLength(Infinity)\r// => 4294967295\r\rtoLength('3.2')\r// => 3" ], "name": "toLength", "longname": "toLength", "kind": "function", "scope": "global", "___id": "T000002R000912", "___s": true, "filepath": "toLength.js" }