Given a javascript object, what is the simplest way to get the number of keys with a particular value?
For example, I have the following javascript obje
Just filter and get the length.
var result = { 1: "PASS", 2: "PASS", 3: "FAIL", 4: "PASS", 5: "FAIL" }; function getCount(s, o) { return Object.keys(result).filter(function (k) { return o[k] === s; }).length; } document.write(getCount('PASS', result));