js check if values in array in another array code example

Example 1: 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"

Example 2: javascript check if array is subset of another

let superSet = ['B', 'C', 'A', 'D'];
let subSet = ['D', 'C'];
let mixedSet = new Set([...superSet, ...subSet]);
let isSubset = mixedSet.size == superSet.length