👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
The Object.values ​​(JavaScript) method retrieves a list of values ​​in an object. You can iterate through the result of the values ​​() method to see the contents of each value in the object.
Objects contain keys and values. Sometimes you just want to get the values ​​back into the object. Suppose we have an object that stores the names of all the people in a collation. You may want to retrieve only the names of the object rather than the keys associated with their name (for example their locations).
is where the Object.values ‚Äã‚Äã() method comes in. This method allows you to see all the values ‚Äã‚Äãin an object. In this guide, we will discuss how to use the Object.values ‚Äã‚Äã() method. We’ll refer to a detailed example method to get you started.
JavaScript Object.values ​​()
Object.values ​​() JavaScript accepts the object and returns its countable property in an array. The values ​​are classified as if you were to loop the object manually and put them in an array.
Let’s take a look at the syntax of this method:.
The Object.values ​​() method takes one argument: the name of the object whose values you want to see. In this syntax, we display the result of the method on the console.
This code returns the names of the players in our JavaScript object : lucy and harry . These names are returned in a list, which we print to the JavaScript console :
Note that the values ​​are in the same order they were in the dictionary.