structuredClone(): deeply copying objects in JavaScript

Spreading is a common technique for copying objects in JavaScript:

Spreading into an Array literal to copy an Array
Spreading into an Object literal to copy a plain object

Spreading has one significant downside – it creates shallow copies: The top le…


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer

Spreading is a common technique for copying objects in JavaScript:

Spreading has one significant downside – it creates shallow copies: The top levels are copied, but property values are shared.

structuredClone() is a new function that will soon be supported by most browsers, Node.js and Deno. It creates deep copies of objects. This blog post explains how it works.

[Read rest of post]


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer


Print Share Comment Cite Upload Translate Updates
APA

Dr. Axel Rauschmayer | Sciencx (2022-01-16T00:00:00+00:00) structuredClone(): deeply copying objects in JavaScript. Retrieved from https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/

MLA
" » structuredClone(): deeply copying objects in JavaScript." Dr. Axel Rauschmayer | Sciencx - Sunday January 16, 2022, https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/
HARVARD
Dr. Axel Rauschmayer | Sciencx Sunday January 16, 2022 » structuredClone(): deeply copying objects in JavaScript., viewed ,<https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/>
VANCOUVER
Dr. Axel Rauschmayer | Sciencx - » structuredClone(): deeply copying objects in JavaScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/
CHICAGO
" » structuredClone(): deeply copying objects in JavaScript." Dr. Axel Rauschmayer | Sciencx - Accessed . https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/
IEEE
" » structuredClone(): deeply copying objects in JavaScript." Dr. Axel Rauschmayer | Sciencx [Online]. Available: https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/. [Accessed: ]
rf:citation
» structuredClone(): deeply copying objects in JavaScript | Dr. Axel Rauschmayer | Sciencx | https://www.scien.cx/2022/01/16/structuredclone-deeply-copying-objects-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.