Мне нужно обновить атрибут имени значения моего объекта по определенному индексу. У меня есть индекс нет, а также массив.
Это мой код,
this.menus.forEach(x => {
let temp = this.menus.findIndex(function (item) {
return item.name == 'Cost Center';
});
// this.menus.values[temp].name=this.newCC;
this.menus[temp].name=this.newCC;
console.log("menu temp",temp);
Это моя структура массива,
Array (11)
0:{_id: "5acc9e6320a7d71ab8372120", name: "DashBoard", link: "dashboard", icon: "fa fa-list", key: "dashboard", …}
1: {_id: "5acc9e6320a7d71ab837211f", name: "My Products", link: "print-products", icon: "fa fa-barcode", key: "print-products", …}
2:{sequence: null, key: "my-saved-jobs", icon: "fa fa-file-text-o", link: "my-saved-jobs", name: "My Saved Jobs", …}
3:{sequence: null, key: "my-placed-orders", icon: "fa fa-list-alt", link: "my-placed-orders", name: "My Orders", …}
4:{_id: "5acc9e6320a7d71ab837211b", name: "Site Design Setup", link: "storefront-setup", icon: "fa fa-university", key: "storefront-setup", …}
5:{_id: "5acc9e6320a7d71ab8372118", name: "Reports", link: "reports", icon: "icon-report", key: "reports", …}
6:{_id: "5accb9425241ed3270585b93", name: "Print Service Category", link: "print-service-category", icon: "fa fa-tasks", key: "print-service-category", …}
7:{sequence: null, key: "my-saved-files", icon: "fa fa-floppy-o", link: "my-saved-files", name: "My Saved Files", …}
8:{sequence: null, key: "product-list", icon: "fa fa-list", link: "product-list", name: "Product List", …}
9:{_id: "5acc9e6320a7d71ab8372119", name: "Deal Code", link: "deal- code", icon: "fa fa-university", key: "deal-code", …}
10:{sequence: null, key: "cost-center", icon: "icon-costCenter", link: "cost-center", name: undefined, …}
length:11
Может кто-нибудь помочь решить мою проблему?
Пожалуйста, ответьте.