Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript testing if value is in array

Is there a function in javascript to do this - test if a given value (a string in my case) exists in an array (of strings)? I know I could just loop over each value, but I'm wondering if js has a shorthand for this.

like image 490
bba Avatar asked Mar 02 '26 16:03

bba


1 Answers

jquery has .inArray() method. It's the best I know..

like image 86
naugtur Avatar answered Mar 05 '26 05:03

naugtur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!