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.
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