Answers for "save eventlisstner in browser js"

7

localStorage

// localStorage for objects, arrays or any data type
var obj = {
	firstName: "Bob",
    lastName: "Jeff",
    age: 13
}
localStorage.setItem("itemname", JSON.stringify(obj)); // Save the obj as string
var item = JSON.parse(localStorage.getItem("itemname")); 
// ^^ Parse string then set `item` as the obj
Posted by: Guest on May-20-2020
0

localstorage

localStorage.setItem('name', 'Bob') // make/set a key/value
var username = localStorage.getItem('name') // get the key
console.log(username) // log the key
// This data will be saved even after you close the page
Posted by: Guest on November-02-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language