javascript show localstorage size

Solutions on MaxInterview for javascript show localstorage size by the best coders in the world

showing results for - "javascript show localstorage size"
Rafael
15 Aug 2018
1 function getUsedLocalStorageSpace(){
2        var allStrings = '';
3        for(var key in window.localStorage){
4            if(window.localStorage.hasOwnProperty(key)){
5                allStrings += window.localStorage[key];
6            }
7        }
8        return allStrings ? 3 + ((allStrings.length*16)/(8*1024)) + ' KB' : 'Empty (0 KB)';
9 };
10 getUsedLocalStorageSpace();//