Objects have existed in JavaScript for a long time. They form the backbone of JavaScript, as almost every data type can be associated with objects. (new String()
, new Number()
, new Boolean()
, and so on). You'll often find yourself working and manipulating objects all the time when working with web applications or JavaScript in general.
ES6, ES2016 (ES7), and ES2017 (ES8) introduce a lot of new properties and methods associated with objects. Let us take a look at them.
ES8 introduced the Object.values()
method so that a programmer can retrieve all the values of an object as an array. This was earlier possible by manually iterating over every property of the object and storing its value in the array.
Here's an example:
const obj = { book: "Learning ES2017 (ES8)", author: "Mehul Mohan", publisher: "Packt", useful: true }; console.log(Object.values(obj));
The output will be:
["Learning ES2017 (ES8)", "Mehul Mohan", "Packt", true]