• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Miscellaneous / Check if at least one element of values is included in arr

Check if at least one element of values is included in arr

Check if at least one element of values is included in arr

Use Array.prototype.some() and Array.prototype.includes() to check if at least one element of values is included in arr.

const includesAny = (arr, values) => values.some(v => arr.includes(v));

// Examples
includesAny([1, 2, 3, 4], [2, 9]); // true
includesAny([1, 2, 3, 4], [8, 9]); // false

Source

https://www.30secondsofcode.org/js/s/includes-any

Miscellaneous

Related Snippets:

  • Get and set the text of an element (without markup)
  • How To Get All Unique Values and Remove Duplicates in a JavaScript Array
  • Sorting by an Object Property
  • Delete, replace, and add items to an array at specific indexes

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers