NeonMan,
const storage = {
save(name, value = []) {
localStorage.setItem(name, JSON.stringify(value));
},
restore(name) {
return JSON.parse(localStorage.getItem(name)) || [];
},
clear(name, age) {
this.save(name, this.restore(name).filter(item => Date.now() - item.id < age));
}
};
storage.clear('todo', 30 * 24 * 60 * 60 * 1000);
let tasks = storage.restore('todo'); // [{ id: ..., ... }, { id: ..., ... }, ...]