Index an array of arrays with an array of indexes in javascript

You can use Array.reduce() to go through the indexes and get the element you want.

// array[a][b][c][d][e]
var indexes = [ a, b, c, d, e ];

var element = indexes.reduce(function(prev, curr){
    return prev[curr];
}, array);

Leave a Comment