Answers for "why do we add window to localstorage"

5

javascript localstorage

localStorage.setItem("user_name", "Bob");

document.body.addEventListener("click", function(){
  alert(localStorage.getItem("user_name"))
});
Posted by: Guest on May-14-2020
0

copy localstorage javascript

var data = JSON.parse(/*previously copied stringified JSON from clipboard*/);
Object.keys(data).forEach(function (k) {
  localStorage.setItem(k, data[k]);
});
Posted by: Guest on September-15-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language