Q:

what is local storage and session storage in javascript

//localStorage - stores data with no expiration date. window. sessionStorage - stores data for one session (data is lost when the browser tab is closed)
1

if (sessionStorage.clickcount) {
  sessionStorage.clickcount = Number(sessionStorage.clickcount) + 1;
}
else {
  sessionStorage.clickcount = 1;
}

document.getElementById("result").innerHTML = "You have clicked the button " +

sessionStorage.clickcount + " time(s) in this session.";
 
0

 if (localStorage.clickcount) {
  localStorage.clickcount = Number(localStorage.clickcount) + 1;

 } else {
  localStorage.clickcount = 1;
}

 document.getElementById("result").innerHTML = "You have clicked the button " +

localStorage.clickcount + " time(s)."; 
0

New to Communities?

Join the community