A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/web-storage/Storage/key below:

key · WebPlatform Docs

key Summary

Returns the name of the nth key in the list.

Method of apis/web-storage/Storageapis/web-storage/Storage

Syntax
var  = object.key(index);
Parameters index
Data-type
unsigned long

A zero-based index of the list entry, up to the length of the collection.

Return Value

Returns an object of type StringString

Examples

This 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 specifications
W3C Web Storage Specification
W3C Editor’s Draft
Attributions

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