HTMLStorage object
Represents the list of key/value pairs that have been assigned to a single storage area.
![]() ![]() |
Members
The HTMLStorage object has these types of members:
Methods
The HTMLStorage object has these methods.
| Method | Description |
|---|---|
| clear |
Removes all key/value pairs from the Web Storage area. |
| getItem |
Retrieves the current value associated with the Web Storage key. |
| key |
Retrieves the key at the specified index in the collection. |
| removeItem |
Deletes a key/value pair from the Web Storage collection. |
| setItem |
Sets a key/value pair. |
Properties
The HTMLStorage object has these properties.
| Property | Description |
|---|---|
|
Returns a reference to the constructor of an object. | |
|
Retrieves the length of the key/value list. | |
|
Retrieves the remaining number of UTF-16 characters allowed for the storage object. |
Standards information
Remarks
Each Storage object provides access to a list of key/value pairs, which are sometimes called items. Keys are strings, and any string (including the empty string) is a valid key. Items contain values (which are also strings) and associated metadata.
Each Storage object is associated with a list of key/value pairs when it is created. Multiple Storage objects, such as two instances of localStorage, can be associated with the same list of key/value pairs simultaneously.
Examples
Key names are exposed as properties on this object. For example, the following statements are equivalent:
sessionStorage.setItem('myKey', '...'); sessionStorage['myKey'] = '...'; sessionStorage.myKey = '...';
See also

