When processing a very large in-memory array of uniform (same-type) JavaScript objects (each with just a few columns)...
Is there any impact on performance and/or or any other penalty to consider when choosing to iterate through it as row->column versus column->row?
Example
We have 100,000 data rows from a CSV file, each is an object with 10 integer values, and we need to touch every value in it for a certain calculation.
Will it make any difference whether we iterate through it vertically or horizontally? Does the modern V8 care about such things in the slightest?
var data = [...]; // array of many same-type objects;
// horizontal iteration:
for (var p in data[0]) {
for (var i = 0; i < data.length; i++) {
var value = data[i][p]; // current value;
// calculate here from the value;
}
}
// vertical iteration:
for (var i = 0; i < data.length; i++) {
for (var p in data[0]) {
var value = data[i][p]; // current value;
// calculate here from the value;
}
}