• 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:

  • How To Check If An Object Property Is Undefined In JavaScript
  • What is the difference between prefix and postfix operators?
  • Assign keys to an object with the same name
  • Find a specific object in an array of objects

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