1×
Become a member
to unlock all features
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.