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);
More Related Contents:
- Creating a JavaScript global array with static elements?
- Array.prototype.fill() with object passes reference and not new instance
- JavaScript “new Array(n)” and “Array.prototype.map” weirdness
- Convert array to JSON
- Why can I add named properties to an array as if it were an object?
- Is the order of elements in a JSON list preserved?
- JavaScript: How to join / combine two arrays to concatenate into one array?
- How to find if an array contains a specific string in JavaScript/jQuery?
- Sum JavaScript object propertyA values with the same object propertyB in an array of objects
- How to change value of object which is inside an array using JavaScript or jQuery?
- How might I extract the property values of a JavaScript object into an array?
- Sampling a random subset from an array
- Convert JavaScript array of 2 element arrays into object key value pairs
- Selecting last element in JavaScript array [duplicate]
- Best way to convert string to array of object in javascript?
- How to create an array in JavaScript whose indexing starts at 1?
- How to check if a string array contains one string in JavaScript? [duplicate]
- MongoDB select where in array of _id?
- Remove duplicate objects from an array using javascript
- How can I use optional chaining with arrays and functions?
- Removing undefined values from Array
- How to remove duplicates from a two-dimensional array? [closed]
- Javascript – sorting array by multiple criteria
- Strange behavior of an array filled by Array.prototype.fill()
- What does the Array method `reduce` do?
- Group javascript array object by same key
- javaScript: Can a comma occur after the last set of values in an array?
- Array.push return pushed value?
- Declare an array in TypeScript
- Array of object deep comparison with lodash