Convert an object's values to an array

suggest change

Given this object:

const obj = {
    a: "hello",
    b: "this is",
    c: "javascript!",
};

You can convert its values to an array by doing:

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

console.log(array); // ["hello", "this is", "javascript!"]

Object.values(obj) returns that same array. Both skip symbol keys. String-key order follows the usual own-property order.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents