43
rated 0 times
[
45]
[
2]
/ answers: 1 / hits: 72663
/ 11 Years ago, mon, april 8, 2013, 12:00:00
I'm just getting started with Javascript and using the Underscore library. I see they have all sorts of utility function, like _.contains. Is there a way to make this work on objects?
var indexes = [ {'id': 1, 'name': 'jake' }, {'id':4, 'name': 'jenny'}, {'id': 9, 'name': 'nick'}, {'id': 1, 'name': 'jake' }, {'id':4, 'name': 'jenny'} ];
if (_.contains(indexes, {'id':1, 'name': 'jake'})) {
console.log(contains);
}
Most of the examples they show have simple arrays with strings or numbers in them. I was wondering what I can do to use their utility functions like _.contains for objects. Thanks.
More From » underscore.js