Object Entries
Object.entries() converts object properties to an array of [key, value] pairs, enabling iteration and manipulation of object contents.
Syntax:
Object.entries( obj )
Example: Here is the basic example of above-mentioned method.
Javascript
// creating an object constructor // and assigning values to it const obj = { 0: 'adam' , 1: 'billy' , 2: 'chris' }; // Displaying the enumerable property [key, value] // pairs of the object using object.entries() method console.log(Object.entries(obj)[1]); |
Output
[ '1', 'billy' ]
JS 2015 or ECMAScript 6 (ES6)
JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization and readability.