local stroge code example
Example 1: store data in browser javascript
var testObject = { 'one': 1, 'two': 2, 'three': 3 };
localStorage.setItem('testObject', JSON.stringify(testObject));
var retrievedObject = localStorage.getItem('testObject');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
Example 2: 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');