This allows them to, for example, be stored on disk and later restored, or cloned with
structuredClone(), or shared between workers using
The serialization may not include all the properties and other aspects of the original object.
For example, a serialization of a
DOMException must include the
message properties, but whether it includes other properties is implementation dependent.
As a result, a deserialized object may not be an identical clone/copy of the original object.
The new deserialized object will however be a deep copy, so any properties that were serialized from the original object and then deserialized into the new object will share no references with the original object.
In some cases when serializing and deserializing an object, it makes sense to transfer some resources rather than creating a copy. Objects that can be transferred are called Transferable objects.
All primitive values are serializable. Not all objects are serializable objects. The objects that can be serialized are listed in: The structured clone algorithm > Supported types
Note: Serializable objects are marked up in Web IDL files with the attribute