Returns the name of the nth key in the list.
Method of apis/web-storage/Storageapis/web-storage/Storage
Syntaxvar = object.key(index);
Parameters index
A zero-based index of the list entry, up to the length of the collection.
Return ValueReturns an object of type StringString
ExamplesThis example creates a new localStorage item (a timestamp) and sets it with a unique key, then executes a function, then retrieves the item’s name by its key index (0 in this case, as it is the first key) and reports its value.
window.localStorage.setItem('timestamp', (new Date()).getTime());
doSomethingElse();
startTimeKey = window.localStorage.key(0);
startTime = window.localStorage.getItem(startTimeKey);
alert("The doSomethingElse function was called at: " + startTime);
Notes
The returned key can be any string, including the empty string. The order of keys may change when items are added to the collection. This method will throw an “Invalid Argument” exception if index is out of range.
Related specificationsMicrosoft Developer Network: Windows Internet Explorer API reference Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4