localStorage knowledge summary

I. What is localStorage: local storage,
two localStorage and sessionStorage any difference.?
1. localStorage permanently stored in the local
close, the data browser window disappear 2. sessionStorage
Three Characteristics of localStorage.?
1. Store at about 5M
2. permanent memory
3. data type String must be
4. the homologous protection policy (the same port / protocol with the / same domain) receiving
5 with a browser compatible with
four localStorage operations:
1. Create or modify
let storage = window.localStorage;
. storage attribute = 'value';
Storage [ 'property'] = value;
storage.setItem ( 'Key', 'value');
2. Get
the let = Storage window.localStorage;
storage.key
Storage [ 'Key']
Storage .getItem ( 'Key')
3. remove
the let = Storage window.localStorage;
storage.removeItem ( 'Key');
4. Clear
let storage = window.localStorage;
storage.clear();
5. 获取所有的key(key())
let storage = window.localStorage;
for(let i = 0,len = storage.length;i < len ;i ++){
console.log(storage.key(i));
}

Guess you like

Origin blog.csdn.net/weixin_45052104/article/details/91431918