Quantcast
Channel: How do I check if an array includes a value in JavaScript? - Stack Overflow
Viewing all articles
Browse latest Browse all 66

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

$
0
0

You can use findIndex function to check if an array has a specific value.

arrObj.findIndex(obj => obj === comparedValue) !== -1;

Returns true if arrObj contains comparedValue, false otherwise.


Viewing all articles
Browse latest Browse all 66

Trending Articles



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