Answers for "local storage"

6

local storage

function setItem(name, value) {
  localStorage.setItem(name, value);
}
function getItem(name) {
  localStorage.getItem(name);
}
function deletItem(name) {
  localStorage.removeItem(name);
}
function clearStorage() {
  localStorage.clear();
}
Posted by: Guest on October-26-2020
1

local storage

As the answers here already talk about the coding aspect. I will talk about
the concept.
Local storage is basically an object stored in the specific browser you are 
using in that moment. And thus it is tied to that browser in that device. It's 
duration is infinite so it never expires

If you only want to store data that only lasts for that browser session(
starts when you open a window and ends when you close it) then the best choice
is sessionStorage
Posted by: Guest on November-14-2020
0

local storage

localStorage.setItem('localStorage', 1);
Posted by: Guest on June-04-2021
0

local storage

<form action="2.html" onsubmit="callme()">
    <p>Enter your name</p>
    <input id="tbName" type="text">
    <button type="submit" value="submit">Submit</button>
</form>
<script>
    function callme(){
        var name = document.getElementById('tbName').value;
        sessionStorage.setItem('userName', name);
    }
</script>
Posted by: Guest on September-02-2021
0

local storage

var answer = localStorage.key(1);
// this statement will retrieve the value of the second item in localStorage.
Posted by: Guest on October-11-2021
0

local storage

window.localStorage.setItem("grade","One");
//in this case, the `grade` is the key while `One` is the value.
Posted by: Guest on October-11-2021

Browse Popular Code Answers by Language