This page is for practicing Spread operator, to create shallow copies.

Shallow Copy

The spread operator only creates a shallow copy, meaning it only copies the top-level properties.

Deep Copy

1. JSON.parse(JSON.stringify(original))

JSON.stringify(original) - This converts the object into a string.

JSON.parse(...) - This reads the string and builds a new object from it.

2. Lodash {_.cloneDeep()}

Lodash is a JavaScript helper library — it gives you many easy-to-use tools for working with arrays, objects, and other data.