SAA*_*AAD 7 javascript properties object
可以使不可扩展的对象可扩展吗?
var obj = {};
Object.preventExtensions(obj);
obj.abc = "abc"; // this line is ignored which is normal
//is there a way to make obj extensible againRun Code Online (Sandbox Code Playgroud)
深度克隆怎么样?
obj = JSON.parse(JSON.stringify(obj));
obj.abc = "abc"; // this line is now OK
Run Code Online (Sandbox Code Playgroud)
在本地代码中是可以的,但是附带的任何外部引用obj将不再指向新形成的obj.
| 归档时间: |
|
| 查看次数: |
363 次 |
| 最近记录: |