InterviewHubPRO
Section Overview
Q290

Question 290 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

56%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

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.

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

  var stringArray = ["green", "yellow", "blue"];
  console.log(stringArray.includes("blue")); //true