1var testObject = { 'one': 1, 'two': 2, 'three': 3 };
2
3// Put the object into storage
4localStorage.setItem('testObject', JSON.stringify(testObject));
5
6// Retrieve the object from storage
7var retrievedObject = localStorage.getItem('testObject');
8
9console.log('retrievedObject: ', JSON.parse(retrievedObject));
1// *** JS Storage Get/Set item ***
2
3 let target = document.getElementById("target");
4 let increment = document.getElementById("increment");
5 let count = localStorage.getItem("counter") || 0;
6 target.innerHTML = count;
7
8 increment.addEventListener("click", () => {
9 count++;
10 localStorage.setItem("counter", count);
11 target.innerHTML = count;
12 })
1function set(){
2 var sendJson = JSON.stringify(arrayName);
3 localStorage.setItem('key',sendJson)
4}