zl程序教程

您现在的位置是:首页 >  前端

当前栏目

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

2023-09-14 08:59:11 时间

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.