Skip to content

Instantly share code, notes, and snippets.

@vladilenm
Created February 21, 2020 09:38
Show Gist options
  • Save vladilenm/be8a632e0ebcf1d2c1b2d24b1866231f to your computer and use it in GitHub Desktop.
Save vladilenm/be8a632e0ebcf1d2c1b2d24b1866231f to your computer and use it in GitHub Desktop.
const myNumber = 42
localStorage.removeItem('number')
console.log(localStorage.getItem('number'))
localStorage.setItem('number', myNumber.toString())
console.log(localStorage.getItem('number'))
localStorage.clear()
const object = {
name: 'Max',
age: 20
}
localStorage.setItem('person', JSON.stringify(object))
const raw = localStorage.getItem('person')
const person = JSON.parse(raw)
person.name = 'Vladilen'
console.log(person)
window.addEventListener('storage', event => {
console.log(event)
})
// window.onstorage = () => {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment