Storage

sealed external class Storage(source)

This Web Storage API interface provides access to a particular domain's session or local storage. It allows, for example, the addition, modification, or deletion of stored data items.

MDN Reference

Properties

Link copied to clipboard
val length: Int

Returns the number of key/value pairs.

Functions

Link copied to clipboard
fun clear()

Removes all key/value pairs, if there are any.

Link copied to clipboard
fun getItem(key: String): String?

Returns the current value associated with the given key, or null if the given key does not exist.

Link copied to clipboard
fun key(index: Int): String?

Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.

Link copied to clipboard
fun removeItem(key: String)

Removes the key/value pair with the given key, if a key/value pair with the given key exists.

Link copied to clipboard
fun setItem(key: String, value: String)

Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.