Object Copies in JavaScript

Let's learn how to copy objects. For example, let's say we have some object:

javascriptlet obj = {a: 1, b: 2, c: 3};

Let's make a copy of it. This is done using a special method, like this:

javascriptlet copy = Object.assign({}, obj);

There is also a second approach - via destructuring:

javascriptlet copy = {...obj};