JavaScript Array includes() Method
Clash Royale CLAN TAG#URR8PPP
<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]-->
JavaScript Array includes() Method
❮ JavaScript Array Reference
Example
Check if an array includes "Mango":
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
<!--
The result of n will be:
true
-->Try it Yourself »
Definition and Usage
The includes() method determines whether an array contains a specified
element.
This method returns true if the array contains the element, and
false if not.
Note: The includes() method is case sensitive.
Browser Support
Method | |||||
---|---|---|---|---|---|
includes() | 47 | 14.0 | 43 | 9 | 34 |
Syntax
array.includes(element, start)
Parameter Values
Parameter | Description |
---|---|
element | Required. The element to search for |
start | Optional. Default 0. At which position in the array to start the search |
Technical Details
Return Value: | A Boolean |
---|---|
JavaScript Version: | ECMAScript 7 |
More Examples
Check if an array includes "Banana", starting the search at position 3:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Banana", 3);
<!--
The result of n will be:
false
-->Try it Yourself »
❮ JavaScript Array Reference