Advertisement
728x90
The Array#includes() method is used to determine whether an array includes a particular value among its entries by returning either true or false. Let's see an example to find an element(numeric and string) within an array.
javascript
1var numericArray = [1, 2, 3, 4];
2
3console.log(numericArray.includes(3)); // true
4
5var stringArray = ["green", "yellow", "blue"];
6
7console.log(stringArray.includes("blue")); //trueAdvertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 30
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
286of476