Quantcast
Viewing latest article 11
Browse Latest Browse All 66

Answer by KRRySS for How do I check if an array includes a value in JavaScript?

Using idnexOf() it is a good solution, but you should hide embedded implementation indexOf() function which returns -1 with ~ operator:

function include(arr,obj) { 
    return !!(~arr.indexOf(obj)); 
} 

Viewing latest article 11
Browse Latest Browse All 66

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>