Storage

The Storage interface of the Web Storage API provides access to a particular domain's session or local storage.

MDN Reference

Properties

Link copied to clipboard
val length: Int

The length read-only property of the Storage object.

Functions

Link copied to clipboard
fun clear()

The clear() method of the Storage interface clears all keys stored in a given Storage object.

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

The getItem() method of the Storage interface, when passed a key name, will return that key's value, or null if the key does not exist, in the given Storage object.

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

The key() method of the Storage interface, when passed a number n, returns the name of the nth key in a given Storage object.

Link copied to clipboard
fun removeItem(key: String)

The removeItem() method of the Storage interface, when passed a key name, will remove that key from the given Storage object if it exists.

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

The setItem() method of the Storage interface, when passed a key name and value, will add that key to the given Storage object, or update that key's value if it already exists.