DEV Community

Discussion on: Storing Local Data with Javascript

Collapse
 
gauravumrani profile image
Gaurav • Edited

Hi, You can store the data in local storage, and if you want the data to be in order, you can do this

  1. Whenever new data is created, store the id also, it should be increment, ex- Date.now().getTime()
  2. Store the data in local storage
  3. The data should be stored in an Array

Example data format =

var data = [{
      id: 1,
      more: data
    }, {
      id: 2,
      more: data
 }];

Now when the user refreshes the page, you can take the data from local storage, sort it by id and display it

Collapse
 
njericooper profile image
Njeri Cooper

Interesting. Thank you!