Best way to get intersection of keys of two objects?
问题 I have two object literals like so: var firstObject = { x: 0, y: 1, z: 2, a: 10, b: 20, e: 30 } var secondObject = { x: 0, y: 1, z: 2, a: 10, c: 20, d: 30 } I want to get the intersection of the keys these two object literals have like so: var intersectionKeys = ['x', 'y', 'z', 'a'] I can obviously do a loop and see if a key with the same name exists in the other object, but I am wondering if this would be a good case for some functional programming and map / filter / reduce usage? I myself