by @codeexamples

How to get all property values in JavaScript object

Home » es6 » How to get all property values in JavaScript object

To get the all property values of a JavaScript object without knowing keys (or properties) we need to use the Object.values() method and forEach() method.

const obj = {
  name: "jio",
  age: 14,
  color: "blue"
}

const values = Object.values(obj);

values.forEach(val=>console.log(val));

Output:

"jio"
14
"blue"