English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Storage clear() method

JavaScript Storage Object

clear()Method to clear all keys stored in the given storage object.

The clear() method belongs to the storage object and can belocalStorageObject orsessionStorrageObject.

Syntax:

localStorage.clear();
sessionStorage.clear();
localStorage.clear();
Test and See‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the clear() method:

Method
clear()43.511.549

Technical Details

Return Value:None
DOM Version:Network Storage API

More Examples

Delete all session storage items:

sessionStorage.clear();
Test and See‹/›

Related References

HTML Tutorial:Web Storage API

Reference: Window (Window)window.localStorage property

Reference: Window (Window)window.sessionStorage property

JavaScript Storage Object