A JavaScript object is a collection of key-value pairs. It is a non-primitive data type that can contain various data types.
The original object is affected because objects are reference types.
The spread operator was introduced in ES6 and can spread values into an object with the three dots in front.
An alternative to the spread operator is the Object.assign() method. You use this method to copy the values and properties from one or more source objects to a target object.
A shallow copy means that the top-level properties of an object are copied to a new object, but if the original object contains references (like objects or arrays), the references themselves are copied rather than the objects they refer to. Thus, changes to nested objects in the copied version will affect the original.
A deep copy means copying all the elements of an object, including nested objects or arrays, so that the original and the copied object do not share any references
On this page of the site you can watch the video online Copy vs Clone Object in JavaScript with a duration of hours minute second in good quality, which was uploaded by the user Gain Tech Knowledge 01 January 1970, share the link with friends and acquaintances, this video has already been watched 3 times on youtube and it was liked by 1 viewers. Enjoy your viewing!