Last active
August 29, 2015 14:25
-
-
Save diegocasmo/5df854f8d34e8acf24d6 to your computer and use it in GitHub Desktop.
Calculates localStorage key and total size occupied by data in MB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var total = 0; | |
for (var key in localStorage) { | |
var keySize = ((localStorage[key].length * 2) / 1024 / 1024).toFixed(2); | |
console.log(key + '=' + keySize + ' MB'); | |
total += parseFloat(keySize); | |
} | |
console.log('total=' + total.toFixed(2) + ' MB'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'Functional version'