Global / Window

structuredClone

Creates a deep clone of a given value using the structured clone algorithm

Syntax

JavaScript
structuredClone(value, options?)

Parameters

ParameterTypeDescription
valueTThe value to be cloned
options{ transfer?: Transferable[] }Options with transferable objects

Return Value

A deep clone of the given value

Examples

Basic Usage
const original = { a: 1, b: { c: 2 } };
const clone = structuredClone(original);
clone.b.c = 99;
console.log(original.b.c); // 2 (unchanged)
Practical Example
const data = {
  date: new Date(),
  set: new Set([1, 2, 3]),
  map: new Map([['key', 'value']]),
};
const clone = structuredClone(data);
console.log(clone.date instanceof Date); // true
Advanced Usage
const nested = { a: [{ b: { c: [1, 2, 3] } }] };
const copy = structuredClone(nested);
copy.a[0].b.c.push(4);
console.log(nested.a[0].b.c.length); // 3 (unchanged)

Understanding structuredClone

The structuredClone method in JavaScript creates a deep clone of a given value using the structured clone algorithm. It belongs to the window object and is one of the most widely used methods for working with window values in modern JavaScript and TypeScript applications.

The method signature is structuredClone(value, options?). It accepts 2 parameters: value, options. When called, it returns a deep clone of the given value. Understanding when and how to use structuredClone() helps you write more expressive, readable code.

Common use cases for structuredClone include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like object-assign, json-parse, json-stringify, enabling you to chain operations together for complex data manipulation pipelines.

Supported in Chrome 98+, Firefox 94+, Safari 15.4+, Edge 98+, and Node.js 17+.

Browser Compatibility

Supported in Chrome 98+, Firefox 94+, Safari 15.4+, Edge 98+, and Node.js 17+.

Related Methods

More Global / Window Methods

Other methods in the Global / Window object

Related Tools

More Global / Window Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.