Object.keys() vs Object.values()
Object.keys() and Object.values() are both JavaScript Object APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. Object.keys(): Returns an array of a given object's own enumerable property names. Its syntax is Object.keys(obj). Object.values(): Returns an array of a given object's own enumerable property values. Its syntax is Object.values(obj). Example of Object.keys(): Object.keys({a:1, b:2}) // ["a", "b"]. Example of Object.values(): Object.values({a:1, b:2}) // [1, 2]. Read the full references for Object.keys() and Object.values() to see edge cases, time complexity, browser support, and the mistakes developers most often make with each. Other Object APIs worth comparing: Object.entries(), Object.assign(), Object.create(), Object.defineProperty(), Object.defineProperties(), Object.freeze(). Both belong to the Object category in the JS Reference documentation, which covers 29 entries in total. Try both in the JavaScript playground to see the behavioral difference live.