150
rated 0 times
[
153]
[
3]
/ answers: 1 / hits: 6605
/ 10 Years ago, wed, september 3, 2014, 12:00:00
I am using UnderscoreJs
in my project. I have to filter an array containing object having properties. I need to filter based on the values. The value can be of any property of the object. ex: mini should fetch both toyota and Honda since mini is present as part of both the objects
[{ name:Toyota minivan, id:506, size: large }, { name:Honda Civic, id:619, size: mini }]
How to do using Underscore. I have tried the following approach but not working.
var searchStr=mini;
var evens = _.filter([arrayData], function(obj){ return _.contains(obj, searchStr); });
Can you please let me know where I am going wrong?
More From » arrays