HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Get the number of local storage item for this domain
The length property returns the number of items stored in the browsers Storage Object, for this particular domain..
The length property belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.
Property | |||||
---|---|---|---|---|---|
length | 4 | 8 | 3.5 | 4 | 10.5 |
DOM Version: | Web Storage API |
---|---|
Return Value: | A Integer, representing the number of stored items |
The same example, but using session storage instead of local storage.
Get the number of session storage item for this domain:
var x = sessionStorage.length;
Loop through each local storage item and display the names:
for (i = 0; i < localStorage.length; i++) {
x = localStorage.key(i);
document.getElementById("demo").innerHTML += x;
}