Search Results

Search found 1 results on 1 pages for 'd777'.

Page 1/1 | 1 

  • Can reducing index length in Javascript associative array save memory

    - by d777
    I am trying to build a large Associative Array in JavaScript (22,000 elements). Do I need to worry about the length of the indices with regards to memory usage? In other words, which of the following options saves memory? or are they the same in memory consumption? Option 1: var student = new Array(); for (i=0; i<22000; i++) student[i] = { "studentName": token[0], "studentMarks": token[1], "studentDOB": token[2] }; Option 2: var student = new Array(); for (i=0; i<22000; i++) student[i] = { "n": token[0], "m": token[1], "d": token[2] }; I tried to test this on Google Chrome DevTools, but the numbers are inconsistent to make a decision. My best guess is that because the Array indices repeat, the browser can optimize memory usage by not repeating them for each student[i], but that is just a guess. Thanks.

    Read the article

1