Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript array includes another array

const array1= ["cheese", "dough", "sauce", "pepperoni"]
const array2= ["mozzarella", "peppers", "chicken", "cheese"]

const isIncluded =  array1.some(value => array2.includes(value))
// true

const values = array1.filter(value => array2.includes(value))
// "cheese"
Comment

javascript check if elements of one array are in another

const found = arr1.some(r=> arr2.includes(r))
Comment

How to check if array includes a value from another array in JavaScript

// How to check if array includes a value from another array in JavaScript
const includesAny = (arr, values) => values.some(v => arr.includes(v));
includesAny([1, 2, 3, 4], [2, 9]); // true
includesAny([1, 2, 3, 4], [8, 9]); // false
Comment

how to check all elements in array includes in another array javascript

// how to check all elements in array includes in another array javascript
const includesAll = (arr, values) => values.every(v => arr.includes(v));
includesAll([1, 2, 3, 4], [1, 4]); // true
includesAll([1, 2, 3, 4], [1, 5]); // false
Comment

if array ontains any item of another array js

const found = arr1.some(r=> arr2.indexOf(r) >= 0)
Comment

PREVIOUS NEXT
Code Example
Javascript :: js redirect to relative url 
Javascript :: install moment in goole dev console 
Javascript :: javascript get current time 
Javascript :: regex special characters javascript 
Javascript :: regular expression for links 
Javascript :: execute javascript function when page loads 
Javascript :: jquery check a radio button 
Javascript :: minus month javascript date 
Javascript :: jquery set checkbox checked unchecked 
Javascript :: javascript listen for double click 
Javascript :: how to remove the parent div from the child in jquery 
Javascript :: javascript date minus seconds 
Javascript :: gdscript yield timer 
Javascript :: javascript insert sibling after 
Javascript :: how express serve public folder 
Javascript :: javascrip reverse text 
Javascript :: passport.authenticate inside a controller 
Javascript :: domain regex 
Javascript :: parsefloat jquery 
Javascript :: js save local storage 
Javascript :: how to make a div scrollable 
Javascript :: iframe in react native 
Javascript :: window.onload 
Javascript :: document ready in jquery 
Javascript :: angular ng serve with custom port 
Javascript :: how to find prime numbers in an array in javascript 
Javascript :: js get first space in string 
Javascript :: reactnavigation 5 hide header 
Javascript :: random password javascript 
Javascript :: get all mondays in calendar+js 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =