What is the most concise and efficient way to find out if a JavaScript array contains an object?
This is the only way I know to do it:
function contains(a, obj) { for (var i = 0; i < a.length; i++) { if (a[i] === obj) { return true; } } return false; }
Is there a better and more concise way to accomplish this?
http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array