返回課程

將物件轉換成 JSON 並還原

重要性:5

user 轉換成 JSON,然後讀回另一個變數。

let user = {
  name: "John Smith",
  age: 35
};
let user = {
  name: "John Smith",
  age: 35
};

let user2 = JSON.parse(JSON.stringify(user));