const arr1 = [ 1, 2, 3 ];
const arr2 = [ 3, 5, 4, 2, 7, 0, 1, 10 ];
let hasAllElems = true;
for (let i = 0; i < arr1.length; i++){
if (arr2.indexOf(arr1[i]) === -1) {
hasAllElems = false;
break;
}
}
console.log(hasAllElems); // output: true
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter