Details about storage in web storage and webstorage
Storage of web storage
I have used a lot of data storage in my recent work. I have written an article about storage blogs to help me better understand the concept. I hope you can criticize and correct it more.
I. web storage is divided into two types:, SessionStorage, localStorage;
Ii. web storage features;
1. easy configuration and reading
2. Large Capacity, sessionStorage about 5 M, localStorage about 20 M
3. Strings can be stored directly. Object Storage is stored after JSON. stringify () encoding.
4. window. sessionStorage
1) The lifecycle is to close the browser window
2) data can be shared in the same window.
5. window. localStorage
1) takes effect permanently, unless manually deleted
2) Multi-Window sharing in the same browser
Iii. Compatibility with web Storage;
Iv. web storage string operation api (sessionStorage and localStorage operation api are the same)
Obtain local storage
window.localStorage.getItem( ‘age' )
Store a key-Value Pair locally
window.localStorage.setItem( key,value )
Deletes a value stored locally.
window.localStorage.removeItem( key )
Clear Local Storage
window.localStorage.clear()
Obtain the key value of the Local Storage
window.localStorage.key( index )
V. OSS APIs
1. Store an object locally
window.localStorage.setItem ('socketArr',JSON.stringify( { key:1 } ) );
2. obtain local storage objects
JSON.parse(localStorage.getItem ('socketArr') );
If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!