Languages
[Edit]
EN

JavaScript - check if array contains any element of another array

0 points
Created by:
trincot
360

In this article, we would like to show you how to check if array contains any element of another array in JavaScript.

Quick solution:

Note:

Array includes() was introduced in ES6 (around 2016).

 

Alternative solution

Edit

In this section, we present an alternative solution that works in older web browsers and Node.js.

See also

Edit
  1. JavaScript - check if array contains value

References

Edit
  1. Array.prototype.some() - JavaScript | MDN
  2. Array.prototype.includes() - JavaScript | MDN
  3. Array.prototype.indexOf() - JavaScript | MDN

Alternative titles

  1. JavaScript - check if array contains any item from another array
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join