How to check if JavaScript Array Includes Multiple Values?

Are you wondering how to check if a JavaScript array includes multiple values?

Just keep reading, as we will show you the solutions on how you can do it simply yet effectively.

But before we talk about how to check for multiple values that exist in an array in JavaScript, let’s quickly go over what an array is in JavaScript.

What is Array in JavaScript?

An array is a way to store many values in one or single variable.

In JavaScript, arrays start counting from zero, so the first value is at index 0, the second value is at index 1, and so on.

What is includes() method?

The includes() method is a built-in function in JavaScript that determines whether an array includes a certain value among its entries.

The includes() method only checks for the presence of a single value in an array.

Here’s the syntax of includes() method:

array.includes(searchElement[, fromIndex])

📌searchElement

The value to search for.


📌fromIndex (optional)

The position in the array at which to begin searching for searchElement.

A negative value searches from the index of array.length + fromIndex by asc. Defaults to 0.

Moreover, the includes() method in JavaScript for arrays will return true if a value is present in the array, and false if it is not.

For example:

let sample = ["hi", "welcome to", "itsourcecode"];
let sample2 = "itsourcecode";

let result = sample.includes(sample2);

console.log(result); 

In this example, we have an array sample that contains the values “hi”, “welcome to”, and “itsourcecode.”

We also have a variable sample2 that contains the value “itsourcecode.”

We use the includes() method to check if the sample array includes the value of sample2, which is “itsourcecode.”

The result is true because “itsourcecode” is included in the sample array.

When you log the value of result to the console, it outputs true.

Output:

true

How to use includes() to check multiple values exist in an array in JavaScript?

As mentioned previously, the includes() method in JavaScript is designed to solely check for the existence of a single value within an array.

If you want to check for the presence of multiple values includes in an array in JavaScript, you can use the every() method in combination with the includes() method.

Here’s an example that shows how to use the every() method to check if an array includes all of the selected items

const samplearr= [10, 20, 30, 40, 50];
const selectedItems = [10, 20, 50];
const result = selectedItems.every(item => arr.includes(item));
console.log(result);

In this example, we use the every() method to check if every item in the selectedItems array is included in the samplearr array.

The result is true because both 10, 20, and 30 are included in the samplearr array.

Output:

true

Solutions on how to check JavaScript array includes multiple values?

To check if multiple values exist in array in JavaScript, here’s the solutions you need.

Aside from using every() method that we illustrate above, here are the different ways to check if an array includes multiple values in JavaScript.

Solution 1: Use the filter() method

Here’s the example code using the filter() method in combination with the includes() method:

const samplearr = ["It", "source", "code"];
const selectedItems = ["It", "code"];
const result = selectedItems.filter(item => samplearr.includes(item)).length === selectedItems.length;
console.log(result); 

In this solution, we use the filter() method to create a new array that contains only the items from the selectedItems array which are also present in the arr array.

The filter() method checks each item in the selectedItems array using the includes() method to see if it exists in the samplearr array.

If all items from selectedItems are found in samplearr, the length of the new array will be the same as the length of selectedItems, indicating that all items are included.

Output:

true

Solution 2: Use for loop

Here’s the example solution using for loop.

const samplearr = [100, 200, 300, 400, 500];
const selectedItems = [100, 200, 500];
let result = true;
for (let i = 0; i < selectedItems.length; i++) {
    if (!samplearr.includes(selectedItems[i])) {
        result = false;
        break;
    }
}
console.log(result);

In this solution, we use a for loop to go through each item in the selectedItems array. We check if each item is present in the samplearr array using the includes() method.

If we find any item that is not in the samplearr array, we set the result as false and stop the loop.

This means that not all of the items in the selectedItems array are included in the arr array.

Output:

true

Here’s the example code, if we input item that is not in the samplearr array:

const samplearr = [100, 200, 300, 400, 500];
const selectedItems = [10, 20, 50];
let result = true;
for (let i = 0; i < selectedItems.length; i++) {
    if (!samplearr.includes(selectedItems[i])) {
        result = false;
        break;
    }
}
console.log(result);

Output:

false

Conclusion

In conclusion, this article provided several solutions on how to check if a JavaScript array includes multiple values.

The includes() method in JavaScript can be used to check the presence of a single value in an array, returning true if the value is found and false if it is not.

The every() method can be combined with includes(). To check for the existence of multiple values exist in array in JavaScript.

Additionally, the filter() method can be utilized to create a new array containing only the items that are present in both arrays, and a for loop can be employed to iterate through the selected items and check their inclusion in the array using includes().

These methods offer flexible approaches to efficiently verify the presence of multiple values in a JavaScript array.

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

You can also check out the following article:

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