JavaScript Storage API

Storage Object

The Storage object of the Web Storage API provides access to session storage or local storage for a specific domain. This allows you to read, add, modify, and delete stored data items.

Storage object properties and methods

Properties/Methods Description
key(n) Returns the name of the nth key in the storage.
length Returns the number of data items stored in the Storage object.
getItem(keyname) Returns the value of the specified key name.
setItem(keyname, value) Adds a key to the storage or updates the value of a key (if it already exists).
removeItem(keyname) Removes a key from the storage.
clear() Clears all keys from the storage.

Pages related to Web Storage API

Properties Description
window.localStorage Allows key/value pairs to be stored in a web browser. Stores data without an expiration date.
window.sessionStorage Allows key/value pairs to be stored in a web browser. Stores data for a session.