JSFiddle - React, Tailwind, and code Playground
HTML
<div id="e"></div>
JavaScript
function deep_pluck(array, identities) {
var this_id = identities.shift();
if (identities.length > 0) {
return deep_pluck(array[this_id], identities);
}
return array[this_id];
}
var cars = {
"bentley": {
"suppliers": [
{
"location": "England",
"name": "Sheffield Mines"},
{
"location": "sss",
"name": "sss"}
]
// ...
}
};
$("#e").text(deep_pluck(cars, ['bentley', 'suppliers', 0, 'name']));