Sometimes, we want to converting object to array with JavaScript.
In this article, we’ll look at how to converting object to array with JavaScript.
How to converting object to array with JavaScript?
To converting object to array with JavaScript, we use the Object.values
method.
For instance, we write
const inputObj = { a: "foo", b: [1, 2, 3], c: null, z: 55 };
const arr = Object.values(inputObj);
to call Object.values
with inputObj
to return an array with all the property values in inputObj
.
Conclusion
To converting object to array with JavaScript, we use the Object.values
method.