Save Javascript objects in sessionStorage

后端 未结 9 749
抹茶落季
抹茶落季 2020-12-02 05:14

SessionStorage and LocalStorage allows to save key/value pairs in a web browser. The value must be a string, and save js objects is not trivial.

var user = {         


        
9条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 05:23

    Session storage cannot support an arbitrary object because it may contain function literals (read closures) which cannot be reconstructed after a page reload.

提交回复
热议问题