I have an array of cars like this:
[{ name:"Toyota Minivan", id:"506" }, { name:"Honda Civic", id:"619" }]
var x =!!_.where(cars, {id:'506'}).length;
Your code does work (once you fix the syntax errors in the object array): http://jsfiddle.net/ArPCa/
var cars = [{ name:"Toyota Minivan", id:"506"}, { name:"Honda Civic", id:"619"}];
var x =!!_.where(cars, {id:'506'}).length;
console.log('value: ' + x);
returns "value: true". So there must be a problem somewhere else.
But, a better way to do this might be some
:
var y = _.some(cars, function(c) {
return c.id == '506';
});