X_AE_A-12

localStorage APIs

May 8th, 2020
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   saveTasks(tasks)
  2.   {
  3.     localStorage.setItem("tasks", JSON.stringify(tasks));
  4.   }
  5.  
  6.   getTasks()
  7.   {
  8.     if (localStorage.getItem("tasks") === null) return {}
  9.     else return JSON.parse(localStorage.getItem("tasks"));
  10.   }
  11.  
  12.   removeTask(id)
  13.   {
  14.     var tasks = this.getTasks();
  15.     delete tasks.tasks[id];
  16.     this.generateTaskArray();
  17.   }
RAW Paste Data