猿问

同一数据Object.keys,Object.values和Object.entries获得的个

同一数据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]); 

}

输出结果:

  • 设置自定义对象


https://img4.mukewang.com/5c496650000102ec03330552.jpg

输出结果:


https://img1.mukewang.com/5c49665700011f1e07720251.jpg

慕哥9229398
浏览 500回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答