walid mahmoud
Published in : 2022-02-13
This is the only way I know to do it:
function contains(a, obj) { for (var i = 0; i < a.length; i++) { if (a[i] === obj) { return true; } } return false;}
Is there a better and more concise way to accomplish this?
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Yasen Sayed Date : 2022-02-13
Best answers
8
Best answers
8
You can use this in the modern browsers, code to check the array
Also, you can the indexOf method like this:
Joseph Morgan Date : 2022-02-13
Best answers
11
Best answers
11
also, you can use this way using indexOf