This method is like `indexOf` except that it iterates over elements of `array` from right to left.
lastIndexOf([1, 2, 1, 2], 2)
// => 3
// Search from the `fromIndex`.
lastIndexOf([1, 2, 1, 2], 2, 2)
// => 1
Name | Type | Attribute | Description |
---|---|---|---|
array | The array to inspect. | ||
value | The value to search for. | ||
fromIndex | The index to search from. |
{ "comment": "/**\r\n * This method is like `indexOf` except that it iterates over elements of\r\n * `array` from right to left.\r\n *\r\n * @since 0.1.0\r\n * @category Array\r\n * @param {Array} array The array to inspect.\r\n * @param {*} value The value to search for.\r\n * @param {number} [fromIndex=array.length-1] The index to search from.\r\n * @returns {number} Returns the index of the matched value, else `-1`.\r\n * @example\r\n *\r\n * lastIndexOf([1, 2, 1, 2], 2)\r\n * // => 3\r\n *\r\n * // Search from the `fromIndex`.\r\n * lastIndexOf([1, 2, 1, 2], 2, 2)\r\n * // => 1\r\n */", "meta": { "range": [ 723, 1130 ], "filename": "lastIndexOf.js", "lineno": 24, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100005591", "name": "lastIndexOf", "type": "FunctionDeclaration", "paramnames": [ "array", "value", "fromIndex" ] }, "vars": { "length": "lastIndexOf~length", "index": "lastIndexOf~index" } }, "description": "This method is like `indexOf` except that it iterates over elements of\r`array` from right to left.", "since": "0.1.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Array", "value": "Array" } ], "params": [ { "type": { "names": [ "Array" ] }, "description": "The array to inspect.", "name": "array" }, { "type": { "names": [ "*" ] }, "description": "The value to search for.", "name": "value" }, { "type": { "names": [ "number" ] }, "optional": true, "defaultvalue": "array.length-1", "description": "The index to search from.", "name": "fromIndex" } ], "returns": [ { "type": { "names": [ "number" ] }, "description": "Returns the index of the matched value, else `-1`." } ], "examples": [ "lastIndexOf([1, 2, 1, 2], 2)\r// => 3\r\r// Search from the `fromIndex`.\rlastIndexOf([1, 2, 1, 2], 2, 2)\r// => 1" ], "name": "lastIndexOf", "longname": "lastIndexOf", "kind": "function", "scope": "global", "___id": "T000002R000523", "___s": true, "filepath": "lastIndexOf.js" }