![]() |
In JavaScript, a shallow copy refers to creating a new object or array and copying the top-level structure of the original data structure. However, for nested objects or arrays within the original structure, only references to those nested objects or arrays are copied, rather than duplicating them. This means that changes made to nested objects or arrays within the original structure will also affect the copied structure, and vice versa. Example: Here, Javascript
Output
[ 10, [ 20, 3 ], { key: 'updated' } ] [ 1, [ 20, 3 ], { key: 'updated' } ] |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |