Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to find the size of localStorage in HTML?
localStorage is used to persist information across multiple sessions. It has a maximum size of 5MB.
Example
You can try to run the following code snippet to check the size allocated −
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"); Advertisements
