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 ]