D
D
DimaPolishuk2016-07-31 20:42:33
JavaScript
DimaPolishuk, 2016-07-31 20:42:33

How, after converting from a string to an object in LOCALSTORAGE, put this object into an array and after updating the page so that it is already there?

i have an array of objects

var tasks = [{
        name: "Задача № 1",
        selectedProject: 'select project',
        dateBegin: new Date('07 24, 2016 19:58:49'),
        dateFinish: new Date('07 24, 2016 19:58:59')
      }, {
        name: "Задача № 2",
        selectedProject: 'timer',
        dateBegin: new Date('07 25, 2016 19:58:30'),
        dateFinish: new Date('07 25, 2016 19:59:15')
      }]

It is necessary that after filling in some fields, the object is stored in LocalStorage.
How then to get the object from LocalStorage and place it in an array, and so that after the update it is shown to the user?
I do like this:
localStorage.setItem("tasks", serialTask);
var serialTask = JSON.stringify(tasks); 
var returnTask = JSON.parse(localStorage.getItem("tasks"));

all that remains is to add a new object to the tasks array and to display it to the user after the update, help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2016-07-31
@Sanasol

todomvc.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question