Q:

Getting keys of an object that has same values

I have an object like:
 Object {v: 1, b: 1, n: 1, m: 1, c: 2, d: 3}

I am trying to collect keys that has same values and generate an array (so in this case [v, b, n, m].  
So if I know 1, how can I get v,b,n,m in an array? 

A:

You can use Object.keys() to get key values of the object, then filter values based on your condition using filter()

var obj = {
    v: 1,
    b: 1,
    n: 1,
    m: 1,
    c: 2,
    d: 3
  },
  val = 1;

var res = Object.keys(obj).filter(function(v) {
  return obj[v] == val;
});

document.write('<pre>' + JSON.stringify(res, null, 4) + '</pre>');

