Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Compose Objects with Object.assign to Create a Direct Copy

    javascriptJavaScript

    Coupling objects together can create a brittle relationship. If the prototype object is mutated or replaced later in development, that can cause issues to any new implementations of 'child' objects that use those properties. Instead, let's use Object.assign to compose objects. This method creates a direct copy of all properties and does not reference the source object's properties in memory.