> For the complete documentation index, see [llms.txt](https://hannahpun.gitbook.io/leetcode-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hannahpun.gitbook.io/leetcode-note/tools/json.xx-localstorage.md).

# JSON.xx / localStorage

```
const deepCLone = structuredClone(original);
```

| Method           | Description |                                                     |
| ---------------- | ----------- | --------------------------------------------------- |
| JSON.parse()     | 字串轉物件       | `JSON.parse('{"a":1}') // {a: 1}`                   |
| JSON.stringify() | 物件轉字串       | `let obj = {a: 1} JSON.stringify(obj) // '{"a":1}'` |
|                  |             |                                                     |

localStorage / SessionStorage

| Method                           | Description   |   |
| -------------------------------- | ------------- | - |
| localStorage.set("name", "內容")   | 內容只能是字串       |   |
| localStorage.get("name")         |               |   |
| sessionStorage.set("name", "內容") | browser 關閉就沒了 |   |
| sessionStorage.get("name")       |               |   |
