Home > Article > Web Front-end > How to find the size of localStorage in HTML?
#localStorage is used to save information across multiple sessions. Its maximum size is 5MB.
You can try running the following code snippet to check the allocated size -
var sum = 0; // loop for size for(var i in localStorage) { var amount = (localStorage[i].length * 2) / 1024 / 1024; sum += amount; document.write( i + " = " + amount.toFixed(2) + " MB"); } document.write( "Total = " + sum.toFixed(2) + " MB");
The above is the detailed content of How to find the size of localStorage in HTML?. For more information, please follow other related articles on the PHP Chinese website!