简体   繁体   中英

Javascript - using sessionStorage vs variables

I have an Ext-JS(Sencha) mobile application. After a user logs in, i load some data from the server in which I store in variables for the users session. I was wondering if it was better to use sessionStorage vs putting these into variables, or if it even made a difference. (The data is sometimes pretty large, but it's not static enough to put into localStorage).

Are there any advantages to using sessionStorage, from a performance standpoint, over in-memory variables ?

Thanks

I would say the advantage is that session storage will go across page loads. If the data is not going to outlast a page load just use variables.

It really comes down to: a single value vs. JSON . Unless you're stashing your data really deeply in JSON and require looping to get to it, there is no real performance difference.

JSON is more convenient in that you have save the session data in one go, rather than have to iterate over separate variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM