MeshWorld India LogoMeshWorld.
others1 min read

includes() Method in JavaScript

Listen to ArticleAI Speech
~1 min read narration
100%
includes() Method in JavaScript

ES2016 Specifications included the includes() method for Array data structure.

The includes() method check if an array includes a certain element, returning true or false as appropriate.

Syntax

array.includes(searchElement);

Example

const array = ["Red", "Orange", "Yellow", "Olive", "Green"];

if (array.includes("Red")) {
  console.log("Red was found in the array"); // true
} else {
  console.log("Red was not found in the array"); // false
}

Note: The includes() method is case sensitive.

Hope you find this helpful.

Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Parimal Ghadiyali
Primary Author

Parimal Ghadiyali

A web geek, industry-experienced web developer & instructor residing in India ๐Ÿ‡ฎ๐Ÿ‡ณ. Passionate about learning new things and making things on the Internet.

Explore Author Archive
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive