Web APIs

Storage.getItem()

Try the free JavaScript compiler

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

NameTypeDescription
keystringStorage 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);}
JavaScript Reference