xxxxxxxxxx
var army= ["Marcos", "DeltaForce", "Seals", "SWAT", "HeadHunters"];
if(army.indexOf("Marcos") !== -1) {
console.log("Yes, the value exists!")
}else{
console.log("No, the value is absent.")
}
xxxxxxxxxx
myArray = Array(/*element1, element2, etc...*/);
// If the array 'myArray' contains the element 'valueWeSearch'
if(myArray.includes(valueWeSearch))
{
// Do something
}
xxxxxxxxxx
if (typeof array != "undefined" && array != null && array.length != null && array.length > 0) {
// array exists and is not empty
}
xxxxxxxxxx
typeof array != "undefined"
&& array != null
&& array.length != null
&& array.length > 0