Elective Course

Course Recommendation:

includes() JavaScript Array includes() Method

Definition and Usage This method returns if the array contains the specified element.true , otherwise returnfalse

Note:includes() .

Method is case-sensitive.

Example

Example 1

Check if the array contains "Banana", starting the search from position 3:
Check if the array contains "Mango":

var n = fruits.includes("Banana", 3);

var n = fruits.includes("Mango");

Example 2

Check if the array contains "Banana", starting the search from position 3:
var fruits = ["Banana", "Orange", "Apple", "Mango"];

var n = fruits.includes("Banana", 3);

Try It Yourself

Syntaxarrayelement.includes( start,

)

Parameter Description
element Required. The element to search for.
start Optional. Default 0. The position in the array where the search begins.

Technical Details

Return Value: Boolean
JavaScript Version: ECMAScript 7

Browser Support

The numbers in the table indicate the first browser version that fully supports this method.

Chrome Edge Firefox Safari Opera
Chrome 47 Edge 14 Firefox 43 Safari 9 Opera 34
December 2015 December 2015 December 2015 September 2015 December 2015

Note:Edge 13 (and earlier versions) does not support includes() Methods.

Related Pages

Tutorial:JavaScript Array

Tutorial:JavaScript Array Const

Tutorial:JavaScript Array Methods

Tutorial:JavaScript Sorting Arrays

Tutorial:JavaScript Array Iteration