What is the shortest and most efficient technique to determine whether a JavaScript array has a value?
This is the only method I know:
function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
Is there a more efficient and succinct method to achieve this?