javascript - How is structured clone algorithm different from deep copy -
there's mdn article states that:
the structured clone algorithm new algorithm defined html5 specification serializing complex javascript objects. it's more capable json
so, believe means it's more capable cloning in way:
json.parse(json.stringify(obj))
suggested in this thread. json way has many drawbacks not supporting circular references, dropping not supported json spec, functions, , representing date object strings.
i thought structured clone algorithm deep copy algorithm implemented many libraries. however, it's listed on same page words:
if want deep copy of object (that is, recursive copy of nested properties, walking prototype chain), must use approach. following possible example.
so i'm confused , don't know structured algorithm or how it's different deep copy. help? don't want read spec, maybe libraries implemented it, can read source code.
Comments
Post a Comment