js access localstorage code example
Example 1: save to local storage
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
localStorage.clear();
Example 2: localstorage js
localStorage.setItem('monChat', 'Tom');
localStorage.getItem('myCat');
localStorage.removeItem('myCat');
Example 3: localstorage
localStorage.setItem('users', 'vilh');
users = [
{
id: 1,
name: 'vilh',
},
{
id: 2,
name: 'zidane'
},
]
localStorage.setItem('users', users);
localStorage.setItem('users', JSON.stringify(users));
var retrievedUsername = localStorage.getItem('users');