Use lodash's some function.
It's concise, accurate and has great cross platform support.
The accepted answer does not even meet the requirements.
Requirements: Recommend most concise and efficient way to find out if a JavaScript array contains an object.
Accepted Answer:
$.inArray({'b': 2}, [{'a': 1}, {'b': 2}])
> -1
My recommendation:
_.some([{'a': 1}, {'b': 2}], {'b': 2})
> true
Notes:
$.inArray works fine for determining whether a scalar value exists in an array of scalars...
$.inArray(2, [1,2])
> 1
... but the question clearly asks for an efficient way to determine if an object is contained in an array.
In order to handle both scalars and objects, you could do this:
(_.isObject(item)) ? _.some(ary, item) : (_.indexOf(ary, item) > -1)