Array Copies in JavaScript
Let's learn how to copy arrays. As an example, let's have some array:
javascriptlet arr = [1, 2, 3, 4, 5];
Let's make a copy of it. This is done using a special method, like this:
javascriptlet copy = Object.assign([], arr);
There is also a second approach - via destructuring:
javascriptlet copy = [...arr];