localstorage操作
作者:互联网
window.localstorage
存值,修改
localStorage.setItem('key', 'value')
localStorage.Key = 'value'
localStorage['key'] = 'value'
取值
localStorage.getItem('key')
localStorage.key
localStorage['key']
删除
localStorage.removeItem('key')
delete localStorage['name']
delete localStorage.name
获取所有key
for(key in localStorage){
console.log(key);
}
获取所有的值
localStorage.valueOf();
清除所有的值
localStorage.clear()
判断是否具有某个Key ,hasOwnProperty方法
localStorage.hasOwnProperty('key')
标签:key,localStorage,value,localstorage,hasOwnProperty,Key,操作 来源: https://www.cnblogs.com/sunzihui/p/16186919.html