I have two arrays as below.
bulkSheet[] - Original array
resultsArray[] - Checking array
I am comparing first element of 'bulkSheet' array with 'resultArray'. Below code is what I have done so far. It executes fine but take long time and gives Exceeded maximum execution time error.
for(var line in bulkSheet) {
for (var line2 in resultsArray)
{
if(bulkSheet[line][0] == resultsArray[line2][0])
{
// matched items
}
}
}
Is there any fastest way?
indexOf(value)method. If the return value fromindexOf()is -1, then there is no match. If there is a match, it will return the index placement of the match in the array being tested. From the index number you can return that value, or overwrite it if you wish. So,var isMatched = secondArray.indexOf(value from loop of first array); if (isMatched !== -1) {var matchedValFromArray2 = arrayTwo[isMatched]};