Categories
JavaScript Answers

How to converting object to array with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *