Periksa apakah array pertama berisi semua elemen javascript
// Not Supported in IE 9-11
const arr1 = ['pizza', 'cola'];
const arr2 = ['pizza', 'cake', 'cola'];
const containsAll = arr1.every(element => {
return arr2.includes(element);
});
console.log(containsAll); // true
// Supported in IE 9-11
const arr1 = ['pizza', 'cola'];
const arr2 = ['pizza', 'cake', 'cola']
const containsAll = arr1.every(element => {
return arr2.indexOf(element) !== -1;
});
console.log(containsAll); // true
Coding Era