What is most concise/efficient way to find out if a javascript array contains an obj?
This is the only way I know to do it:
contains(a, obj){
for(var i = 0; i < a.length; i++) {
if(a[i] === obj){
return true;
}
}
return false;
}
Is there a better/more concise way to accomplish this?
This is very closely related to this question which addresses finding objects in an array using indexOf.