I have two array arrays in Javascript for example
var array1 = [[10, 2], [11, 4], [12, 30], [13, 17], [14, 28]];
var array2 = [[8, 13], [9, 19], [10, 6], [11, 7], [12, 1]];
I want to get a set of arrays from array1which correspond to the first element of each arrayarray2
in my example, an example: array1and array2have an array with the first element as 10 11and 12, therefore, it should return
[[10, 2], [11, 4], [12, 30]];
is there a simple and efficient way using pure javscript or lodash, underscor framework or something like that. Without iterating and matching on one of these two arrays?