FrontendDeveloper.in

JavaScript question detail

How do you check whether or not an array includes a particular value

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.

var numericArray = [1, 2, 3, 4];
console.log(numericArray.includes(3)); // true

var stringArray = ["green", "yellow", "blue"];
console.log(stringArray.includes("blue")); //true
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399