JavaScript Array includes[]
Examples
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes["Mango"];
Try it Yourself »
fruits.includes["Mango"];
Start the search at position 3:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes["Banana", 3];
Try it Yourself »
fruits.includes["Banana", 3];
Definition and Usage
The includes[] method returns true if an array contains a specified value.
The includes[] method returns false if the value is not found.
The includes[] method is case sensitive.
Syntax
array.includes[element, start]
Parameters
Parameter | Description |
element | Required. The value to search for. |
start | Optional. Start position. Default is 0. |
Return Value
Type | Description |
A boolean | true if the value is found, otherwise false. |
Browser Support
includes[] is an ES7 feature [JavaScript 2016]. It is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
includes[] is not supported in internet Explorer or Edge 13 [or earlier].
Related Pages
Array Tutorial
Array Const
Array Methods
Array Sort
Array Iterations