Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js array includes multiple items

function inArray(needle, haystack, matchAll = false) {
    if (matchAll) {
        return needle.every(i => haystack.includes(i));
    } else {
        return needle.some(i => haystack.includes(i));
    }
}

let result = inArray(needle, haystack, true);
Source by www.gavsblog.com #
 
PREVIOUS NEXT
Tagged: #js #array #includes #multiple #items
ADD COMMENT
Topic
Name
5+9 =