javascript - jQuery: how to check if a specific element is already in an array -


this question has answer here:

how can check if var element exists or not in array sites?

var sites = array['test','about','try']; var element = 'other'; 

you can use indexof() method following.

if(sites.indexof(element) > -1) {     //exist } 

Comments

Popular posts from this blog

c++ - list<myClass<int> * > sort -

SoapUI on windows 10 - high DPI/4K scaling issue -

java - why am i getting a "cannot resolve method" error on getApplication? -