📜  如果不存在则创建 localStorage 键 + 值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:51.548000             🧑  作者: Mango

代码示例1
//create localStorage key + value if not exist
if(localStorage){
   localStorage.myPageDataArr={"name"=>"Dan","lastname"=>"Bonny"}; 
}

//when browser closed - psedocode
$(window).unload(function(){
  localStorage.myPageDataArr=undefined;
});