How to create and clone a JSON object?

后端 未结 8 736
独厮守ぢ
独厮守ぢ 2020-12-13 18:04

I was wondering how can I create a JSON (JS) object and then clone it.

8条回答
  •  春和景丽
    2020-12-13 18:42

    Just do

    var x = {} //some json object here
    var y = JSON.parse(JSON.stringify(x)); //new json object here
    

提交回复
热议问题