JSON.xx / localStorage

const deepCLone = structuredClone(original);
MethodDescription

JSON.parse()

ๅญ—ไธฒ่ฝ‰็‰ฉไปถ

JSON.parse('{"a":1}') // {a: 1}

JSON.stringify()

็‰ฉไปถ่ฝ‰ๅญ—ไธฒ

let obj = {a: 1} JSON.stringify(obj) // '{"a":1}'

localStorage / SessionStorage

MethodDescription

localStorage.set("name", "ๅ…งๅฎน")

ๅ…งๅฎนๅช่ƒฝๆ˜ฏๅญ—ไธฒ

localStorage.get("name")

sessionStorage.set("name", "ๅ…งๅฎน")

browser ้—œ้–‰ๅฐฑๆฒ’ไบ†

sessionStorage.get("name")

Last updated