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 -

c - Defining floating point constants, how many digits are useful? -

C# Apple Bonjour - how to monitor service records within Windows -