What is Object.values in JavaScript?


Object.values() is a method that returns an array of all the values of the enumerable properties of an object.

This method is helpful for getting an overview of all the data contained in an object. It can be used to filter or manipulate data before being outputted to a console or displayed on a web page.

The following example shows how to use the Object.values() method to print the values of the object myObj to the console:

var myObj = {
    firstName: "John",
    lastName: "Doe",
    age: 24};

console.log(Object.values(myObj));
// The console output will be:[ "John", "Doe", 24 ]
💡
Need a writer? Want to work with me? I have a subscription copywriting service available at Zipply.io. Subscribe to a set number of words and split it into as many copy assets as you need. Scale your startup, small business, or MVP. Upgrade, downgrade and pause at any time. Start your subscription here.