Intro to Object.assign() in ES6

Benji Kay
Benji JS
Published in
2 min readMar 29, 2016

This is a video tutorial on using the Object.assign() method included in JavaScript’s latest major update. Object.assign() is a super handy tool for copying or merging objects that ought to be in every JS developer’s toolkit.

“Intro to Object.assign() in ES6" on YouTube

P.S.: I forgot to point out one gotcha with passing empty objects to Object.assign in order to make copies — nested properties are assigned by reference instead of value, so mutating your copy will also mutate the original object:

So take care not to make that mistake! Thanks for watching. :)

Referenced links:

Composition over Inheritance on FunFunFunction by Mattias Petter Johansson

Learning JavaScript Design Patterns: The Mixin Pattern by Addy Osmani

✉️ Subscribe to Codeburst’s once-weekly Email Blast, 🐦 Follow Codeburst on Twitter, and 🕸️ Learn Full Stack Web Development.

You can follow me on Twitter @okaybenji

--

--

Benji Kay
Benji JS

Game developer at GoldFire Studios. Contributor to freeCodeCamp, codeburst.io and Hacker Noon. You can follow me on Twitter @okaybenji.