[Javascript] JSON.parse, structuredClone, loadsh.cloneDeep

Both JSON.parse(JSON,strigify())& structuredClone doesn't work with Dateand function.

var foo = {name: 'foo', bar: () => 'bar'}
var foo2 = structuredClone(foo)
// caught DOMException: Failed to execute 'structuredClone' on 'Window': () => 'bar' could not be cloned.
 

 

Only lodash.cloneDeep is working as expected in any cases.

posted @ 2023-04-18 13:36  Zhentiw  阅读(36)  评论(0编辑  收藏  举报