Pushing data to object/array for later comparison

2034 views javascript

I'm trying to store strings in a object/array for later comparison. I have no idea if my approach is correct.

The idea: I'll be using the data to compare if there's been changes in the HTML where the strings are from. If there are changes the script is gonna send a notification with information on what changes there is.

So I have a function that needs to push data into either an object or an array. I need to store the data for later use, where I need to compare if there's any changes. It's specifically a scheme of classes.

An example of what the object/array is gonna look after the data is injected:

    obj = 
      "mon": { 
              0:{date:date, info:info, class:class}
              1:{date:date, info:info, class:class}
              2:{date:date, info:info, class:class}
      "tue": {...},

And so on... So the object/array is gonna contain data for every class, for every day. I need to be able to compare the stored obj.mon.0 with the new obj.mon.0, as an example.

So my question is:
What's the best approach, in an object as above, or in a array?
How do I go about storing information in the object/array for every class, on every day?
And is this even the easiest approach for this context?

Thank you for your time.

answered question

1 Answer


Array is probably the best to choose here.

and you can keep the date, info and class as object.

Please share your suggestions too.

posted this

Have an answer?


Please login first before posting an answer.