Interactive demonstration of browser localStorage API methods
Note: This demo uses the prefix "lsdemo_" to keep its data separate from other apps on this domain
๐ Storage Statistics
Total Items
0
Estimated Size
0 KB
โ setItem(key, value)
setItem() stores a key-value pair in localStorage. Both key and value must be strings.
๐ getItem(key)
getItem() retrieves the value associated with a key. Returns null if the key doesn't exist.
๐๏ธ removeItem(key)
removeItem() deletes a specific key-value pair from localStorage.
๐ key(index)
key() returns the key name at a specific index position. Useful for iterating through all items.
๐งน clear()
clear() removes all key-value pairs from localStorage. Use with caution!
๐พ Current localStorage Contents
No items in localStorage
๐ฆ Storing Complex Data (JSON)
localStorage only stores strings. To store objects/arrays, use JSON.stringify() when setting and JSON.parse() when getting.