Node.js examples for Array:Array Value
Fetch the array and return matches arr.where({checked: true})
Array.prototype.where = function (obj) { var self = this , container = []//w w w . jav a2 s . c om , i , ln = self.length , params = Object.keys(obj) , match = function (index) { var errors = 0; for (var j = 0; j < params.length; j += 1) { if (self[index][params[j]] != obj[params[j]]) { errors += 1; } } return errors > 0 ? false : true; } for (i = 0; i < ln; i += 1) { if (match(i)) { container.push(self[i]); } } return container; }