Cloning JSON not working as expected

This question already has an answer here:

  • How do I correctly clone a JavaScript object? 54 answers

  • When you do:

    var json_2 = json_1
    

    you're actually not "cloning" the object you're merely aliasing it. So all operation on json_1 will be mirrored on json_2 and vice versa. To really clone your object take a look at: https://stackoverflow.com/a/728694/2003420

    链接地址: http://www.djcxy.com/p/24774.html

    上一篇: Object.Freeze Javascript

    下一篇: 克隆JSON不按预期工作