Skip to main content
InterviewHubPRO
Section Overview
Q290

Question 290 of 536

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

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

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

mid LevelCode ExampleData Structures

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