Gets the index at which the first occurrence of `value` is found in `array` using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) for equality comparisons. If `fromIndex` is negative, it's used as the offset from the end of `array`.
indexOf([1, 2, 1, 2], 2)
// => 1
// Search from the `fromIndex`.
indexOf([1, 2, 1, 2], 2, 2)
// => 3
Name | Type | Attribute | Description |
---|---|---|---|
array | The array to inspect. | ||
value | The value to search for. | ||
fromIndex | The index to search from. |
{ "comment": "/**\r\n * Gets the index at which the first occurrence of `value` is found in `array`\r\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\r\n * for equality comparisons. If `fromIndex` is negative, it's used as the\r\n * offset from the end of `array`.\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=0] 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 * indexOf([1, 2, 1, 2], 2)\r\n * // => 1\r\n *\r\n * // Search from the `fromIndex`.\r\n * indexOf([1, 2, 1, 2], 2, 2)\r\n * // => 3\r\n */", "meta": { "range": [ 757, 1051 ], "filename": "indexOf.js", "lineno": 24, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100003609", "name": "indexOf", "type": "FunctionDeclaration", "paramnames": [ "array", "value", "fromIndex" ] }, "vars": { "length": "indexOf~length", "index": "indexOf~index" } }, "description": "Gets the index at which the first occurrence of `value` is found in `array`\rusing [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\rfor equality comparisons. If `fromIndex` is negative, it's used as the\roffset from the end of `array`.", "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": 0, "description": "The index to search from.", "name": "fromIndex" } ], "returns": [ { "type": { "names": [ "number" ] }, "description": "Returns the index of the matched value, else `-1`." } ], "examples": [ "indexOf([1, 2, 1, 2], 2)\r// => 1\r\r// Search from the `fromIndex`.\rindexOf([1, 2, 1, 2], 2, 2)\r// => 3" ], "name": "indexOf", "longname": "indexOf", "kind": "function", "scope": "global", "___id": "T000002R000373", "___s": true, "filepath": "indexOf.js" }