Daniel Daniel - 10 months ago 28
Javascript Question

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

How can I check if the

var element
exists or not in the array

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


You can use indexOf() method like following.

if(sites.indexOf(element) > -1) {