同一数据Object.keys,Object.values和Object.entries获得的个数不同
使用localStorage
localStorage.setItem(`0`,`你好`);
localStorage.setItem(`1`,`再见`);
localStorage.setItem(`2`,`byb`);
localStorage.setItem(`name`,`nono`);
console.log(Object.keys(localStorage));
console.log(Object.values(localStorage));
console.log(Object.entries(localStorage));
console.log(`---------`);
for(var a in localStorage){
console.log(localStorage[a]);
}
输出结果:
设置自定义对象
输出结果:
相关分类