• 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 all the elements in values are included in arr

Check if all the elements in values are included in arr

Check if all the elements in values are included in arr

Use Array.prototype.every() and Array.prototype.includes() to check if all elements of values are included in arr.

const includesAll = (arr, values) => values.every(v => arr.includes(v));

// Examples
includesAll([1, 2, 3, 4], [1, 4]); // true
includesAll([1, 2, 3, 4], [1, 5]); // false

Source

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

Miscellaneous

Related Snippets:

  • Insert an HTML string before the start of the specified element
  • Remove falsy values from an array
  • Finding a specific object in an array of objects
  • How To Copy To The Clipboard Using JavaScript

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