JavaScript Array.includes(): Check if array contains specified value

Do you really want to know how to use the JavaScript array.includes() method to check if an array contains a specified value?

Read on to discover how to leverage the array includes() method in JavaScript to check if an array contains a specific value.

In this article, you’ll learn how to effectively use the array.includes() method in different scenarios and understands its case sensitivity.

What is JavaScript array includes()method?

The array.includes() method in JavaScript is a handy tool that helps you find out if a certain value exists in an array or if array contains the specified value.

It does this by going through each item in the array and comparing it to the value you’re looking for.

If it finds a match, the array.includes() method returns true; if not, it returns false.

Syntax

array.includes(searchElement[, fromIndex]) ✅

Parameters

searchElement (Required)

The value to search for in the array.

fromIndex (Optional)

The fromIndex parameter in the array determines the starting point for the search for the searchElement. If fromIndex is a positive value, the search starts at that index in the array.

If it’s negative, the search starts at arr.length + fromIndex, effectively counting back from the end of the array. If fromIndex is not provided, the search starts from the beginning of the array, which is index 0.

Return value

The array.includes() method returns a Boolean (true or false). It will return true if the array contains the specified value, and false if not.

Here’s an example:

let subjects = ["Math", "English", "Programming"];
console.log(subjects.includes("Programming"));✅  
console.log(subjects.includes("Software Engineering")); 

true

false

In our example code above, the first console log returns true because “Programming” is included in the subjects array.

The second console log returns false because “Software Engineering” is not included in the subjects array.

Moreover, the array.includes() method in JavaScript is case sensitive. It simply means that it treats lowercase and uppercase letters as distinct values.

For instance, if you have an array [“a”, “b”, “c”], the method includes(“A”) would return false because “A” (uppercase) is not the same as “a” (lowercase).

If you want to perform a case-insensitive check, you would need to convert both the array elements and the value you’re checking to the same case (either all to lowercase or all to uppercase) before calling includes().

Supported browser

✔ Chrome

✔ Edge

✔ Firefox

✔Opera

✔Safari

How to use JavaScript array.includes() to check if an array contains a specified value?

Here’s how you can use the Array.includes() method in JavaScript to check if an array contains a specified value:

let array = [10, 20, 30, 40, 50];

let valueToFind = 50;

if (array.includes(valueToFind)) ✅ {
console.log(`The array contains the value ${valueToFind}.`);
} else {
console.log(`The array does not contain the value ${valueToFind}.`);
}

As you can see, in our given example the array.includes() method is used to check if the array contains the valueToFind.

If the array contains the valueToFind, it prints “The array contains the value 50.” If it doesn’t, it prints “The array does not contain the value 50.”

Output:

The array contains the value 50.

Different ways on how to check if array contains specified value

As we mentioned earlier, you can use an array.includes() method to check if an array contains a specified value in JavaScript.

Aside from array.includes, here are a few different ways which you may also use:

Using the Array.indexOf() method

Here’s an example:

let array = [100, 200, 300, 400, 500];
let valueToFind = 100;

if (array.indexOf(valueToFind) !== -1) ✅  {
console.log(`The array contains the value ${valueToFind}.`);
} else {
console.log(`The array does not contain the value ${valueToFind}.`);
}

As observed, array.indexOf() yields the initial index where a specific element is located within the array. If the element is not present, it returns -1.

Output:

The array contains the value 100.

Using the Array.find() method

Here’s an example:

let array = [100, 200, 300, 400, 500];
let valueToFind = 200;

if (array.find(element => element === valueToFind))✅  {
console.log(`The array contains the value ${valueToFind}.`);
} else {
console.log(`The array does not contain the value ${valueToFind}.`);
}

In this method, Array.find() returns the first element in the array that satisfies the provided testing function. Otherwise undefined is returned.

Output:

The array contains the value 200.

Conclusion

In conclusion, the array.includes() method in JavaScript is used to easily check if an array contains a specific value.

This method is case-sensitive and returns a boolean value, making it highly versatile for various scenarios.

In addition to array.includes(), we’ve looked at alternative methods like array.indexOf() and array.find(), expanding the ways you can interact with arrays in JavaScript.

We are hoping that this article provides you with enough information that helps you understand the JavaScript array includes.

If you want to dive into more JavaScript topics, check out the following articles:

Thank you for reading Itsourcecoders 😊.

Frequently Asked Questions

Is JavaScript still worth learning in 2026?
Yes. JavaScript runs on 98% of websites for the front-end, dominates the back-end via Node.js, powers mobile apps through React Native, builds desktop tools through Electron, and is the scripting layer for most AI tooling (LangChain.js, OpenAI SDK, Vercel AI). Whether you target web, mobile, AI, or full-stack capstones, JavaScript is the broadest single language you can learn.
What is the difference between var, let, and const?
var is function-scoped, hoisted to the top of its scope, and can be redeclared, which leads to bugs in modern code. let is block-scoped (only visible inside the nearest {}) and can be reassigned. const is block-scoped and cannot be reassigned, although object contents can still mutate. Default to const for everything, switch to let only when you actually need to reassign, and avoid var in any code written after 2017.
Which JavaScript version should I target in 2026?
Target ES2020 (ES11) as the safe baseline because every modern browser and Node.js 14+ supports it fully. ES2022 adds useful features like top-level await, private class fields with the # prefix, and the .at() array method. If you are writing for older browsers (IE11 or older Android WebViews), transpile down with Babel or use a build tool like Vite, esbuild, or webpack.
What is the best free editor for JavaScript?
Visual Studio Code is the industry standard, free, with built-in IntelliSense, debugger, terminal, Git, and a huge extension marketplace (ESLint, Prettier, GitHub Copilot, Tailwind). Install the JavaScript and TypeScript Nightly extension for the latest language features. JetBrains WebStorm is more powerful and free for students with a verified .edu email. For quick scratchpad work, the Chrome DevTools Sources panel includes a workspace and breakpoint debugger.
How do I run JavaScript locally vs in the browser?
In the browser: open DevTools with F12 (or right-click then Inspect), go to the Console tab, type or paste your code, press Enter. For HTML pages, add a script tag pointing to your .js file. Locally with Node.js: download Node from nodejs.org (LTS version), then run node script.js in your terminal from the file folder. Use the same Node setup for backend capstones, API integrations, and scripts that do not need a browser.
What can I build with JavaScript for my BSIT capstone?
Common BSIT capstones in JavaScript: full-stack web apps using React or Vue on the front-end with Node.js and Express on the back-end (MongoDB or MySQL for the database), real-time chat or notification systems using Socket.io, single-page dashboards with Chart.js or D3.js, cross-platform mobile apps with React Native, AI-powered chatbots using OpenAI SDK and LangChain.js, and Chrome extensions for productivity tools. Add Tailwind CSS for the UI and Vercel or Netlify for free deployment.
Caren Bautista

Technical Writer at PIES IT Solution

Responsible for crafting clear, well-structured, and beginner-friendly content across the platform. Handles the writing, proofreading, and editorial review of tutorials, guides, and documentation to ensure every article is accurate, readable, and easy to follow.

Expertise: Technical Writing · Content Creation · Documentation · Editorial Writing · JavaScript · TypeScript · Python · Python Errors · HTTP Errors · MS Excel  · View all posts by Caren Bautista →

Leave a Comment