For this object
in javascript:
div =
{
id: (changeable value),
html = 'div id="divName'+id+'"></div>
}
This is the most basic form that I can present the problem.
I have a function
that creates the above object
and pushes that into an array
.
Except the above reports :
'Uncaught ReferenceError: id is not defined'
It's not a variable
but an object
property, so I'm not confused as to what the error is, but I'm a little unclear on how to reference, as a variable
, a property within the same object
.
I have tried added a method
to the object
- but that method
is also undefined
div =
{
id: (changeable value),
html = 'div id="divName'+getId()+'"></div>',
getId()
{
return this.id;
},
}