Web APIs
Storage.setItem()
Stores a string value under a string key; may throw if storage cannot accept the write. Use an isolated test origin.
Formal Syntax & Structure
javascript syntaxjavascript
storage.setItem(key, value)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Storage key. |
| value | string | Value to store; converted to string. |
Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
const s=sessionStorage;try{s.setItem("bytemind-demo-theme","dark");console.log(s.getItem("bytemind-demo-theme"));}finally{s.removeItem("bytemind-demo-theme");}