Jsref Includes
# JavaScript Array includes() Method
[ JavaScript Array Object](#)
### Example
Check if the array _site_ contains 'tutorial':
let site = ['tutorial', 'google', 'taobao']; site.includes('tutorial'); // true site.includes('baidu'); // false
[Try it Β»](#)
* * *
## Definition and Usage
The includes() method is used to determine whether an array contains a specified value, returning true if found, otherwise false.
[1, 2, 3].includes(2); // true[1, 2, 3].includes(4); // false[1, 2, 3].includes(3, 3); // false[1, 2, 3].includes(3, -1); // true[1, 2, NaN].includes(NaN); // true
* * *
## Browser Support
The numbers in the table specify the first browser version that fully supports the method.
| Method | | | | | |
| --- | --- | --- | --- | --- | --- |
| includes() | 47 | 14 | 43 | 9 | 34 |
* * *
## Syntax
arr.includes(searchElement) arr.includes(searchElement, fromIndex)
* * *
## Parameter Description
| Parameter | Description |
| --- | --- |
| _searchElement_ | Required. The element value to search for. |
| _fromIndex_ | Optional. The index to start searching from. If negative, the search starts from array.length + fromIndex (ascending). Default is 0. |
* * *
## Technical Details
| Return Value: | Boolean. Returns true if the specified value is found, otherwise false. |
| --- |
| JavaScript Version: | ECMAScript 6 |
* * *
## More Examples
### fromIndex Greater Than or Equal to Array Length
If fromIndex is greater than or equal to the array length, false is returned. The array will not be searched:
### Example
var arr = ['a', 'b', 'c']; arr.includes('c', 3); //false arr.includes('c', 100); // false
### Computed Index Less Than 0
If fromIndex is negative, the computed index is used as the starting position to search for searchElement. If the computed index is less than 0, the entire array is searched.
### Example
// Array length is 3// fromIndex is -100// computed index is 3 + (-100) = -97 var arr = ['a', 'b', 'c']; arr.includes('a', -100); // true arr.includes('b', -100); // true arr.includes('c', -100); // true
[ JavaScript Array Object](#)
YouTip