Javascript - Object.entries() and Object.values()

Introduction

Object.entries() and Object.values() are two new methods introduced in ES2017.

The Object.entries() method, when run on an object, returns the object's own enumerable property [key, value] pairs in the same order as that provided by a for-in loop.

It does not enumerate properties in the prototype chain.

Object.values() when passed an object returns an array of its own enumerable property values:

Demo

:
const myObj = { a: 1, b: 42 }; //from   w w  w . ja  va2s  .co m

Object.entries(myObj);     // [['a', 1], ['b', 42]] 

Object.values(myObj);      // [1, 42]

Result