liveBook · Manning

Object.assign

Object.assign is a JavaScript static method that copies enumerable own properties from source objects to a target object and returns the target.

How 2 Manning books explain it

The Joy of JavaScript

Object.assign is a JavaScript built-in function that copies enumerable own properties from source objects to a target object.

How it is used
Composes configuration, API responses, shallow clones, and mixins by copying independent property bags into one object.
How deep it goes
Explains enumerability, ownership, precedence, shallow copying, and setter behavior, while stopping short of recursive cloning.
Examples
Uses configuration defaults, API-response merging, shallow cloning, non-enumerable properties, inherited properties, and mixin method conflicts.
What you can do after
Apply it to construct composed objects, merge defaults, create shallow clones, and predict conflicts between source properties.

Read how The Joy of JavaScript explains Object.assign →

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond

A JavaScript static method that copies the values of enumerable own properties from one or more source objects to a target object and returns that target object.

How it is used
Uses Object.assign to fill default options and extend objects with additional properties.
How deep it goes
Works through source order, target mutation, setters, and own enumerable properties without descending into specification algorithms.
Examples
Uses pizza-tracking map options, enhanced spaceships, a validating setter, and an array copied into an object.
What you can do after
Apply it via Object.assign to set defaults, extend objects, and choose whether the original object is mutated.

Read how Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond explains Object.assign →

Also covered in

What to know first

Related concepts

Questions about Object.assign

What is Object.assign?

Object.assign is a JavaScript static method that copies enumerable own properties from source objects to a target object and returns the target.

Which Manning books explain Object.assign?

The Joy of JavaScript and Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond.

What should I know before learning Object.assign?

Manning books that teach Object.assign usually introduce accessor method, enumerable property, function and object first.

What is the difference between Object.assign and mutation?

Object.assign is a JavaScript static method that copies enumerable own properties from source objects to a target object and returns the target. Mutation is a change to an existing entity, such as a value, state, data structure, or candidate representation.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.