0

I have an associate object.

records: {
   '15/07/2017': [],
   '16/07/2017': [], 
}

I want to add an extra item to the object, at the present moment I am having to use:

Vue.set(self.records, '17/07/2017', []); 

The problem that I have is that the record is added at the end of the list, while I want the record to go to the front of the list. How can this be rectified?

Vlad Vladimir Hercules
  • 1,781
  • 2
  • 20
  • 37
  • 1
    Object keys in javascript have no guaranteed order. When you present the information you'll need to sort it, unless perhaps you use a `Map`. See http://stackoverflow.com/a/5525820/796554 – hughes May 15 '17 at 17:27
  • As hughes javascript objects do not have a particular order, its better that you use an array (if your usecase supports )which are ordered and you can use unshift() of array to add a new entry to the top off your array – Vamsi Krishna May 16 '17 at 09:04

0 Answers0