slice() method returns a shallow copy of an array into a new array object.
This method is fast, but only creates a shallow copy. So, for arrays containing objects, the copied objects are shared between the original and copied array.
concat() method also returns a shallow copy of an array.
ES6 introduced the spread operator
... which can be used to create a shallow copy of an array.
Array.from() method creates a new array instance from a given array.
For deep copying, we can use
Join our community of forward-thinkers and innovators. Subscribe to get the latest updates on courses, exclusive insights, and tips from industry experts directly to your inbox.