ES8 - Object values

This tutorial covers Object values introduced to latest javascript features introduced in ES8, ES2017, with examples.

This post talks about object.values() method and its examples.

object value method

As we already have inbuiltin Object.keys() method to iterate the keys of an object. Prior to ES8, There is no inbuilt method to have support iteration of values. Es8 introduced values() method to iterate the values. How do you iterate object? So for-in loop used to iterate each element of an object.

Object.values() method returns array of values in the same order for-in loop returns the data.

Object.values returns the own properties values of an object, not the values via prototype inheritence.

**Syntax **```javascript Object.values(myobject)

Parameters and returns
- Input parameters - myobject is input provided to iterate the element values
- Return type - returns array of object values.

Let's see an example to print  properties in array

  const obj = {
  id: 's1',
  sal: 1000


Output is

[ 's1', 'tom', 1000 ]
Prev Next