web api instance method
WorkerGlobalScope: structuredClone() method
Available in workers
The structuredClone() method of the WorkerGlobalScope interface creates a deep copy of a given value using the structured clone algorithm.
The method also allows transferable objects in the original value to be transferred rather than cloned to the new object. Transferred objects are detached from the original object and attached to the new object; they are no longer accessible in the original object.
Syntax
structuredClone(value)
structuredClone(value, options)
Parameters
value- : The object to be cloned. This can be any structured-cloneable type.
optionsOptional- : An object with the following properties:
transfer- : An array of transferable objects that will be moved rather than cloned to the returned object.
- : An object with the following properties:
Return value
A deep copy of the original value.
Exceptions
DataCloneErrorDOMException- : Thrown if any part of the input value is not serializable.
Description
See structuredClone() for details of this function.
Examples
See structuredClone() for examples.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.