Object entries() Method
Object.entries() returns an array of key-value pairs from an object, enabling easy iteration and manipulation of object properties.
Syntax:
Object.entries( obj )
Example: In this example, an object “obj” has been created with three property[key, value] pairs, and the Object.entries() method is used to return the first property [key, value] pair of the object.
Javascript
// Creating an object constructor // and assigning values to it let obj = { 0: 'Rahul' , 1: 'Sumit' , 2: 'Rohit' }; // Displaying the enumerable property [key, value] // pairs of the object using object.entries() method console.log(Object.entries(obj)[1]); |
[ '1', 'Sumit' ]
JS 2017 – ECMAScript 2017
JavaScript (JS) 2017, or ECMAScript 2017, introduced some new features in JavaScript. It enhanced asynchronous programming with async functions, provided shared memory and atomics for improved concurrency, and introduced Object.values() and Object.entries() for streamlined object manipulation. These additions expanded JavaScript’s capabilities, making it more versatile and powerful for modern development.
JavaScript (JS) 2017 new features are:
- String padding
- Object entries() Method
- Object values() Method
- async and await
- Object.getOwnPropertyDescriptors
We will explore all the above methods along with their basic implementation with the help of examples.
Contact Us