JavaScript Object.values() Method

In the same order as a for…in the loop, the Object.values() method returns an array of the enumerable property values of an object. This is the only difference: a for…in the loop also enumerates properties in the prototype chain.

Syntax:

Object.values(object)

Parameter: This object is enumerable with its own properties whose values should be returned.

Return Type: Array of values

Example: Users can open the console in the Chrome web browser by pressing ctrl + shift + I.

Javascript




let fullname = {
    firstname: "geeks",
    middlename: "for",
    lastname: "geeks",
};
let name = Object.values(fullname);
console.log(name);


Output

[ 'geeks', 'for', 'geeks' ]

Difference between Object.values and Object.entries Methods

The object is the parent class from which all the javascript objects are inherited and these two methods are the static methods of the Object class as they are called by the class name of the Object class.

Similar Reads

JavaScript Object.values() Method

In the same order as a for…in the loop, the Object.values() method returns an array of the enumerable property values of an object. This is the only difference: a for…in the loop also enumerates properties in the prototype chain....

JavaScript Object.entries() Method

...