Objects
We will learn about new methods, functionality, and syntax improvements added to objects in ES2015.
We'll cover the following
Static object methods
Arrays and strings are not the only data structures that have gained new functionality. Objects have received several new methods and improvements as well. Let’s briefly look at the most important ones:
Object.assign(target, source[ source[...,],])
The Object.assign()
method is the most useful addition because it enables merging one or more objects into an existing object and returns the result as an object. But beware: the existing object is mutated. Hence, you should use this method sparingly. Following is an example to illustrate the point:
Get hands-on with 1400+ tech skills courses.