Rehan Sattar
Rehan Sattar

Rehan Sattar

Understanding Object.values()

Understanding Object.values()

A quick guide to understanding `Object.values()`

Rehan Sattar
ยทJun 18, 2021ยท

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

๐Ÿ‘‰ The Object.values() method returns an array of all the property values of an object.

๐Ÿ‘‰ Syntax


๐Ÿ‘‰ Here are some of the major points you have to remember while using Object.values()

  1. It returns the elements in the same order as that provided by a loop.
  2. The only difference is that a loop enumerates properties in the prototype chain as well.
  3. The result of Object.values() is an array of all the values so you can map all the array methods to it.
  4. This method became part of JavaScript in ES2017.

๐Ÿ‘‰ Example:

const user = {
  name: 'Jhon doe',
  age: 34,
  isActive: false

// Using ``
for (let key in user) {

// Using `Object.values()`
Object.values(user).forEach(value => console.log(value));

๐Ÿ‘‰ References:

๐Ÿ‘‰ Follow me:

Share this