How to get all property values in JavaScript object
To get the all property values of a JavaScript object without the knowing keys (or properties), we can use the built-in Object.values()
method in JavaScript.
The Object.values()
method takes the object as an argument and returns the array of the given object’s own property values.
Here is an example:
const obj = {
name: "jio",
age: 14,
color: "blue"
}
const values = Object.values(obj);
console.log(values);
Output:
["jio", 14, "blue"]