1đź‘Ť
In the comments you mentioned your goal:
“this.list[i].path does not exist, that is what Im trying to create”
…if you literally want to add a property called “path” directly under the object at this.list[i] then you’d write
this.list[i].path = '/testPath'
This will create a new property for the object being held at this.list[i]
.
P.S.
You don’t need your (badly-named) arr
variable at all here.
Using .push()
doesn’t make any sense (and doesn’t work) because this.list[i]
contains an object rather than an array, and also doing that wouldn’t create a property as you wanted.
0đź‘Ť
push is the function of an array but you are trying to push an object in an object that’s why you got this exception.
you can do as below.
this.list[i].path = '/testPath'
path property will be dynamically added in your object this.list[i].