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 Tiago Bértolo for How do I check if an array includes a value in JavaScript?

$
0
0

The fastest method in Javascript to find if an array contains a value is this:

function existsInArrayForIgnoreDataType(arr, targetElem) {  for (let i = 0; i < arr.length; i++) {    if (arr[i] == targetElem) return true  }  return false }

You can find the complete study I did here.


Viewing all articles
Browse latest Browse all 66

Trending Articles



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