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/getItem below:

getItem · WebPlatform Docs

getItem Summary

Returns the current value associated with the given key.

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

Syntax
var  = object.getItem(key);
Parameters key
Data-type
String

The name of the key (a valid UTF-16 string, including the empty string).

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 timestamp by its key and reports it.

window.localStorage.setItem('timestamp', (new Date()).getTime());
doSomethingElse();
startTime = window.localStorage.getItem('timestamp');
alert("The doSomethingElse function was called at: " + startTime);
Notes

Any valid UTF-16 string, including the empty string, is a valid key name. If the specified key does not exist in the list associated with the object, then this method returns null. Attempts to read or write a secured item from script running in the context of an unsecured URL are not permitted.

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