var way = ['things','equipment','car'];
//......
console.log('Было: ', test_array.things.equipment.car.id1); // "00"
array_clone2.id1 = 999;
console.log('Стало: ', test_array.things.equipment.car.id1); // 999
var way = ['things','equipment','car','id1'];
//......
console.log('Было: ', test_array.things.equipment.car.id1); // "00"
array_clone2 = 999;
console.log('Стало: ', test_array.things.equipment.car.id1); // "00"
Сложность именно в написании вложенных циклов который пройдётся по массиву соберёт индексы, следующим циклом переберёт элементы сопоставит с результатом первого цикла if 132=132 и запишет в инпут index у которого родитель с id 132
var obj = {};
sort_id.forEach(id=>{
obj[id] = true;
});
var arr = document.querySelectorAll('li[data-id]');
arr.forEach(li=>{
let id = li.dataset.id;
if (obj[id]) { //Нашли id в массиве sort_id
//Что-то делаем. У нас есть всё: id и соответствующий li. Что ещё надо?
}
});
3 дня вожусь с этим.
var data = {
types: {
type_1: {
max_speed: 300
},
type_2: {
max_speed: 260
}
},
TC: {
transport_1: {
color: "red",
type: "type_2"
},
transport_2: {
color: "blue",
type: "type_1"
}
}
}
var tc = data.TC.transport_1;
console.log("Car:", tc.color); //red
console.log("Speed:", data.types[tc.type].max_speed); //260
{
"types": {
"type_1": {
"max_speed": 300
},
"type_2": {
"max_speed": 260
}
},
"TC": {
"transport_1": {
"color": "red",
"type": "type_2"
},
"transport_2": {
"color": "blue",
"type": "type_1"
}
}
}