structured clone algorithm
copies complex JavaScript objects. It is used internally to transfer data between
工作者
凭借
postMessage()
, storing objects with
IndexedDB
, or copying objects for
other APIs
.
It clones by recursing through the input object while maintaining a map of previously visited references, to avoid infinitely traversing cycles.
函数
objects cannot be duplicated by the structured clone algorithm; attempting to throws a
DATA_CLONE_ERR
异常。
DATA_CLONE_ERR
异常。
lastIndex
property of
RegExp
objects is not preserved.
注意
: Native
Error
types can be cloned in Chrome, and Firefox is
working on it
.
| Object type | 注意事项 |
|---|---|
| All primitive types | However, not symbols. |
| 布尔 对象 | |
| String 对象 | |
| 日期 | |
| RegExp |
lastIndex
is not preserved.
|
Blob
|
|
File
|
|
FileList
|
|
| ArrayBuffer | |
| ArrayBufferView | Including other typed arrays . |
ImageBitmap
|
|
ImageData
|
|
| 数组 | |
| 对象 | 仅 plain objects (e.g. from object literals) |
| 地图 | |
| Set |
window.history
window.postMessage()