Why Cannot set property 'activeTabs' of undefined?

saveStorageTabs function() {
 let getUserData = localStorage.getItem('usersData');
 let tabs = JSON.parse(getUserData);
 let clientID = localStorage.getItem('IDClient');
 $('.wizard .nav-tabs li a').on('show.bs.tab', function (e) {
 tabs[clientID].activeTabs = $(e.target).attr('href');
console.log(tabs[clientID].activeTabs);
 localStorage.setItem('usersData', JSON.stringify(tabs));
});
 var $active = $('.wizard .nav-tabs li.active');
$active.next().removeClass('disabled');
nextTab($active);
 }


What's wrong? Error in this line
tabs[clientID].activeTabs = $(e.target).attr('href');
April 4th 20 at 13:03
1 answer
April 4th 20 at 13:05
Solution
Try this:
tabs[`"${clientID}"`].activeTabs = $(e.target).attr('href');

UPD.
The fact that you refer to the object property and as a property pass a number that is unacceptable. Object properties in js can only be of type string

Find more questions by tags JavaScript