Every line of 'how to store array in localstorage' 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.
96 _saveLocalStorage(data: any) { 97 store.set(LOCAL_STORAGE_NAME, data); 98 }
69 saveObject(key, value) { 70 this.db.insert(this.prefix + key, JSON.stringify(value)); 71 }
112 saveToLocalStorage(key, value) { 113 localStorage.setItem(key, JSON.stringify(value)); 114 }
23 export function store(key: string, value: any) { 24 const bak = context.getItem(key); 25 context.setItem(key, JSON.stringify(value)); 26 return bak; 27 }
1 export function saveToLocalStorage(key: string, value: string): void { 2 (window as any).localStorage.setItem(key, value); 3 }
5 export function saveToLocalStorage (key, value) { 6 window.localStorage.setItem(key, value) 7 }
129 setLocal(key: string, value: string) { 130 if (this._supportsLocal) { 131 localStorage.setItem(key, value); 132 } 133 }
54 function store(storage, key, value) { 55 if (!storage) { throw new Error("Storage object is undefined"); } 56 57 // get 58 if (value === undefined) { 59 var item = storage.getItem(key); 60 return item && JSON.parse(item); 61 // set 62 } else { 63 try { 64 storage.setItem(key, JSON.stringify(value)); 65 } catch (err) { 66 // prevent catching old values 67 storage.removeItem(key); 68 } 69 } 70 }
9 function setValueToLocal(key, val, storage) { 10 const normalizeVal = typeof val === 'string' ? val : JSON.stringify(val) 11 storage.setItem(key, normalizeVal) 12 }
15 function writeStorage(value: string): void { 16 localStorage.setItem(key, value); 17 18 updateLocalState(value); 19 }