1

When dealing with a large number of data points, is an array of objects a poor choice to use? Is it inefficient to perform lookups when the data is in this format?

var list = [
    { date: '12/1/2011', reading: 3, id: 20055 },
    { date: '13/1/2011', reading: 5, id: 20053 },
    { date: '14/1/2011', reading: 6, id: 45652 }
];

Would it be more efficient to have it in the form of a unifying hash table?

var dict = {
    Item 1: {date: '12/1/2011', reading: 3, id: 20055 },
    Item 2: {date: '13/1/2011', reading: 5, id: 20053 },
    Item 3: {date: '14/1/2011', reading: 6, id: 45652 }
};
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Nakul Tiruviluamala
  • 523
  • 1
  • 3
  • 15
  • Short answer: no. –  Dec 31 '20 at 08:58
  • Does this answer your question? [Array vs. Object efficiency in JavaScript](https://stackoverflow.com/questions/17295056/array-vs-object-efficiency-in-javascript) – pilchard Dec 31 '20 at 16:12

0 Answers0