javascript implementse a storage code example

Example 1: 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();
}

Example 2: local database with javascript

//get in GitHub
//more info in https://pouchdb.com
var db = new PouchDB('dbname');

db.put({
  _id: '[email protected]',
  name: 'David',
  age: 69
});

db.changes().on('change', function() {
  console.log('Ch-Ch-Changes');
});

db.replicate.to('http://example.com/mydb');