使用localStorage封装一个Storage 对象
var Storage = (function(){
return {
set:function(key,value,expireSeconds){
localStorage[key]=JSON.stringify({
value:value,
expired:expireSeconds===undefined?undefined:Date.now()+1000*expireSeconds
})
},
get:fucntion(key){
if (localStorage[key]===undefined) {
return
}
var o = JSON.parse(localStorage[key])
if(o.expired===undefined||Date.now()<o.expired){
return 0.value
}else{
delete localStorage[key]
}
}
}
})()