🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › values
Object.values() - JavaScript - MDN Web Docs
5 days ago - The Object.values() static method returns an array of a given object's own enumerable string-keyed property values.
🌐
W3Schools
w3schools.com › jsref › jsref_object_values.asp
JavaScript Object.values() Method
Object.values() returns the values of all object keys (properties).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-object-values-method
JavaScript Object values() Method - GeeksforGeeks
Object.values() takes the object as an argument of which the enumerable property values are to be returned and returns an array containing all the enumerable property values of the given object.
Published: July 12, 2024
🌐
Reintech
reintech.io › blog › tutorial-working-with-object-values
Working with Object.values()
Object.values() is a static method introduced in ES2017 that extracts enumerable property values from an object and returns them as an array.
🌐
Programiz
programiz.com › javascript › library › object › values
JavaScript Object.values() | Programiz
March 18, 2024 - The values() method returns an array of strings that represents all the enumerable property values of the given object.
🌐
Career Karma
careerkarma.com › blog › javascript › javascript: object.values(): a complete guide
JavaScript: Object.values(): A Complete Guide| Career Karma
January 22, 2021 - The Object data type has a values method that works to push the values of the key:value pair to an array and returns it.
🌐
GeeksforGeeks
geeksforgeeks.org › object-values-javascript
Object.values() In JavaScript - GeeksforGeeks
May 22, 2023 - Object.values() takes the object as an argument of which the enumerable own property values are to be returned and returns an array containing all the enumerable property values of the given object.
Find elsewhere
🌐
Codecademy
codecademy.com › docs › javascript › objects › .values()
JavaScript | Objects | .values() | Codecademy
August 22, 2025 - The Object.values() method returns an array containing the values of an object’s own enumerable properties.
Top answer
1 of 16
1166

Depending on which browsers you have to support, this can be done in a number of ways. The overwhelming majority of browsers in the wild support ECMAScript 5 (ES5), but be warned that many of the examples below use Object.keys, which is not available in IE < 9. See the compatibility table.

ECMAScript 3+

If you have to support older versions of IE, then this is the option for you:

for (var key in obj) {
    if (Object.prototype.hasOwnProperty.call(obj, key)) {
        var val = obj[key];
        // use val
    }
}

The nested if makes sure that you don't enumerate over properties in the prototype chain of the object (which is the behaviour you almost certainly want). You must use

Object.prototype.hasOwnProperty.call(obj, key) // ok

rather than

obj.hasOwnProperty(key) // bad

because ECMAScript 5+ allows you to create prototypeless objects with Object.create(null), and these objects will not have the hasOwnProperty method. Naughty code might also produce objects which override the hasOwnProperty method.

ECMAScript 5+

You can use these methods in any browser that supports ECMAScript 5 and above. These get values from an object and avoid enumerating over the prototype chain. Where obj is your object:

var keys = Object.keys(obj);

for (var i = 0; i < keys.length; i++) {
    var val = obj[keys[i]];
    // use val
}

If you want something a little more compact or you want to be careful with functions in loops, then Array.prototype.forEach is your friend:

Object.keys(obj).forEach(function (key) {
    var val = obj[key];
    // use val
});

The next method builds an array containing the values of an object. This is convenient for looping over.

var vals = Object.keys(obj).map(function (key) {
    return obj[key];
});

// use vals array

If you want to make those using Object.keys safe against null (as for-in is), then you can do Object.keys(obj || {})....

Object.keys returns enumerable properties. For iterating over simple objects, this is usually sufficient. If you have something with non-enumerable properties that you need to work with, you may use Object.getOwnPropertyNames in place of Object.keys.

ECMAScript 2015+ (A.K.A. ES6)

Arrays are easier to iterate with ECMAScript 2015. You can use this to your advantage when working with values one-by–one in a loop:

for (const key of Object.keys(obj)) {
    const val = obj[key];
    // use val
}

Using ECMAScript 2015 fat-arrow functions, mapping the object to an array of values becomes a one-liner:

const vals = Object.keys(obj).map(key => obj[key]);

// use vals array

ECMAScript 2015 introduces Symbol, instances of which may be used as property names. To get the symbols of an object to enumerate over, use Object.getOwnPropertySymbols (this function is why Symbol can't be used to make private properties). The new Reflect API from ECMAScript 2015 provides Reflect.ownKeys, which returns a list of property names (including non-enumerable ones) and symbols.

Array comprehensions (do not attempt to use)

Array comprehensions were removed from ECMAScript 6 before publication. Prior to their removal, a solution would have looked like:

const vals = [for (key of Object.keys(obj)) obj[key]];

// use vals array

ECMAScript 2017+

ECMAScript 2016 adds features which do not impact this subject. The ECMAScript 2017 specification adds Object.values and Object.entries. Both return arrays (which will be surprising to some given the analogy with Array.entries). Object.values can be used as is or with a for-of loop.

const values = Object.values(obj);

// use values array or:

for (const val of Object.values(obj)) {
    // use val
}

If you want to use both the key and the value, then Object.entries is for you. It produces an array filled with [key, value] pairs. You can use this as is, or (note also the ECMAScript 2015 destructuring assignment) in a for-of loop:

for (const [key, val] of Object.entries(obj)) {
    // use key and val
}

Object.values shim

Finally, as noted in the comments and by teh_senaus in another answer, it may be worth using one of these as a shim. Don't worry, the following does not change the prototype, it just adds a method to Object (which is much less dangerous). Using fat-arrow functions, this can be done in one line too:

Object.values = obj => Object.keys(obj).map(key => obj[key]);

which you can now use like

// ['one', 'two', 'three']
var values = Object.values({ a: 'one', b: 'two', c: 'three' });

If you want to avoid shimming when a native Object.values exists, then you can do:

Object.values = Object.values || (obj => Object.keys(obj).map(key => obj[key]));

Finally...

Be aware of the browsers/versions you need to support. The above are correct where the methods or language features are implemented. For example, support for ECMAScript 2015 was switched off by default in V8 until recently, which powered browsers such as Chrome. Features from ECMAScript 2015 should be be avoided until the browsers you intend to support implement the features that you need. If you use babel to compile your code to ECMAScript 5, then you have access to all the features in this answer.

2 of 16
514

By using a simple for..in loop:

for(var key in objects) {
    var value = objects[key];
}
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript object methods › javascript object.values()
JavaScript Object.values() Method
May 8, 2024 - The Object.values() method accepts an object and returns its own enumerable property’s values as an array.
🌐
Can I Use
caniuse.com › object-values
Object.values method | Can I use... Support tables for HTML5, CSS3, etc
The Object.values() method returns an array of a given object's own enumerable property values.
🌐
Vultr Docs
docs.vultr.com › javascript › standard library › object › values()
JavaScript Object values() - Get Object Values | Vultr Docs
November 6, 2024 - The values() method in JavaScript is a vital function when working with objects. It retrieves the values of properties in an object and returns them as an array.
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › object › values
Object.values() - JavaScript | MDN
March 27, 2022 - Object.values() returns an array whose elements are the enumerable property values found on the object.
🌐
DigitalOcean
digitalocean.com › community › tutorials › js-object-entries-values
Object.values and Object.entries in JavaScript | DigitalOcean
May 26, 2022 - Extract arrays of values or of key-value pairs using the new Object.values and Object.methods available with ES2017 (ES8).
🌐
npm
npmjs.com › package › object.values
object.values - npm
December 19, 2024 - var assert = require('assert'); var values = require('object.values'); var obj = { a: 1, b: 2, c: 3 }; var expected = [1, 2, 3]; if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') { // for environments with Symbol support var sym = Symbol(); obj[sym] = 4; obj.d = sym; expected.push(sym); } assert.deepEqual(values(obj), expected); if (!Object.values) { values.shim(); } assert.deepEqual(Object.values(obj), expected);
      » npm install object.values
    
Published: Dec 19, 2024
Version: 1.2.1
🌐
Dmitri Pavlutin
dmitripavlutin.com › access-object-keys-values-entries
How to Access Object's Keys, Values, and Entries in JavaScript
August 11, 2020 - The keys of an object is the list of property names. The values of an object is the list of property values.
🌐
Scaler
scaler.com › home › topics › object.values( ) in javascript
Object.values( ) In JavaScript - Scaler Topics
May 4, 2023 - The object values javascript returns an array of property's value of an object that is passed in the Object.values() method.