10 examples of 'clear localstorage js' in JavaScript

Every line of 'clear localstorage js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
70clearLocalStorageList () {
71 if (window.localStorage) {
72 try {
73 localStorage.clear();
74 } catch (e) {
75 alert('localStorage.clear() fail.');
76 }
77 }
78}
104clearLocalStorageList() {
105 if (!!window.localStorage) {
106 try {
107 localStorage.clear();
108 } catch (e) {
109 alert('localStorage.clear() fail.');
110 }
111 }
112}
176public clear(): void
177{
178 this._db.push('/', {}, true);
179}
6clear()
7{
8 if (!this.isSupported()) return;
9 localStorage.clear();
10}
103clear(): void {
104 localStorage.clear();
105}
15public Clear(): void {
16 window.localStorage.clear();
17}
21clear () {
22 valuesMap.clear()
23}
33public clear() {
34 this.localStorage.clear();
35}
45public clear(): void {
46 localStorage.clear();
47}
111function clearLocalStorage() {
112 /* Remove all items which have expired. */
113 for (let ii = 0; ii < localStorage.length; ii++) {
114 const key = localStorage.key(ii);
115 const {user, repo} = parseTimeKey(key);
116 if (user && repo) {
117 const timeMs = mbStrToMs(localStorage.getItem(key));
118
119 if (timeMs) {
120 if (isExpired(timeMs)) {
121 removeFromLocalStorage(makeRemoteDataKey(user, repo));
122 removeFromLocalStorage(makeSelfDataKey(user, repo));
123 removeFromLocalStorage(makeTimeKey(user, repo));
124 }
125 } else {
126 console.warn(_logName,
127 'Unable to parse time: ',
128 localStorage.getItem(key));
129 }
130 }
131 }
132}

Related snippets