I have three arrays in Javascript:
array1 = ["data", "data1", "data2"]
array2 = ["data", "data1", "data2"]
array3 = ["data", "data1", "data2"]
Is there a way I can merge these arrays into one main array so that I can iterate through them using a single loop?
for (let index = 0; index < mainArray.length; index++) {
value1 = mainArray.array1[index];
value2 = mainArray.array2[index];
value3 = mainArray.array3[index];
}
What's the best approach to create the mainArray
that includes all three javascript arrays? Can we use a complex object or JSON object for this purpose?