Last Updated : 11 Jul, 2025
The includes() method in JavaScript returns true if an array contains a specified value, and false if the value is not found. This method simplifies checking for the presence of an element within an array, offering a quick and efficient way to return a boolean result.
Syntaxarray.includes(searchElement, start);Parameters
Return Value :It returns a Boolean value i.e., either True or False.
Example of JavaScript Array includes() MethodHere’s an example of the JavaScript Array.includes() method:
Example 1: Searching for a number in an arrayIn this example, the includes()
method checks if the number 2 is present in the array A
.
// Taking input as an array A
// having some elements.
let A = [1, 2, 3, 4, 5];
// includes() method is called to
// test whether the searching element
// is present in given array or not.
a = A.includes(2)
// Printing result of includes().
console.log(a);
Example 2: Searching for a string in an array
In this example, the includes()
method checks if the string 'cat'
is present in the array name
. Since 'cat'
is not in the array, it returns false
.
// Taking input as an array A
// having some elements.
let name = ['gfg', 'cse', 'geeks', 'portal'];
// includes() method is called to
// test whether the searching element
// is present in given array or not.
a = name.includes('cat')
// Printing result of includes()
console.log(a);
We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete referencearticle.
Supported BrowsersRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4