How to retrieve all localStorage items without knowing the keys in advance?

前端 未结 8 1489
天涯浪人
天涯浪人 2020-12-04 13:59

I want to show all of the keys and storage written before. My code is below. I created a function (allStorage) but it doesn\'t work. How can I do this?

           


        
8条回答
  •  暖寄归人
    2020-12-04 14:41

    for (let [key, value] of Object.entries(localStorage)) {
        console.log(`${key}: ${value}`);
    }
    

提交回复
热议问题