Web APIs
Storage.getItem()
Returns the stored string or null when the key is absent. Storage access itself may fail in restricted contexts.
Formal Syntax & Structure
javascript syntaxjavascript
storage.getItem(key)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Storage key. |
Return Value
string | null
Stored string or null.
Working Example
Example Snippetjavascript
const s=localStorage,k="bytemind-demo-count";try{s.removeItem(k);console.log(s.getItem(k)===null);s.setItem(k,0);console.log(typeof s.getItem(k),s.getItem(k));}finally{s.removeItem(k);}