Storage length Property
Clash Royale CLAN TAG#URR8PPP
<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]-->
Storage length Property
❮ Storage Object
Example
Get the number of local storage item for this domain:
var x = localStorage.length;
Try it Yourself »
Definition and Usage
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.
Browser Support
Property | |||||
---|---|---|---|---|---|
length | 4 | 8 | 3.5 | 4 | 10.5 |
Syntax
localStorage.length;
Or:
sessionStorage.length;
Technical Details
DOM Version: | Web Storage API |
---|---|
Return Value: | A Integer, representing the number of stored items |
More Examples
Example
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;
Try it Yourself »
Example
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;
Try it Yourself »
❮ Storage Object