I am trying to add a key dynamically to an obj but I keep getting error "Can not set property of undefined" But I cant decalre these properties before knowing them. I want them to added dynamically as a key to that object.
var dict = {}
objectarray.forEach((item: Obj) => {
this.dict[item.ID] = "xyz";
});
As per How do I add a property to a Javascript Object using a variable as the name? it seems possible to add property to object dynamically just by using obj[name] = value.
Am I missing something ? Any help ?