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.
Tell me more
×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
jquery has .inArray() method. It's the best I know.. |
|||||||||||
|
There's
From the same MDC documentation page, here's what to include (before using) to make IE work as well:
|
|||
|
For functions that are in php and should be in javascript or I haven't found yet I go to: http://phpjs.org The function you want use if you're just using javascript is in_array here: http://phpjs.org/functions/in_array:432 Otherwise, use the jQuery solution on this page. |
|||
|
in
operator). – annakata Oct 1 '10 at 13:09