Web globals
structuredClone()
Copies supported structured data, including Maps and cyclic objects. It is not a general class instance copier; functions cannot be cloned. Tested on Node.js 22.16.0. Example output (one line per entry): ["2 3 true"].
Formal Syntax & Structure
nodejs syntaxnodejs
structuredClone(value[, options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | unknown | Cloneable input. |
| options | object | Transfer options. |
Return Value
unknown
Cloned value.
Working Example
Example Snippetnodejs
const a = { books: new Map([['a', 2]]) };a.self = a;const b = structuredClone(a);b.books.set('a', 3);console.log(a.books.get('a'), b.books.get('a'), b.self === b);