Console syntax can be used to manage a property by name:
objectArr[i][variables[j]] = 'something';
In other words, get the object from objectArr
in index i
, then find the field named variables[j]
and set this value to 'something'
.
In general terms, this object is o
:
var o = {};
You can set the property by name:
o['propertyName'] = 'value';
And access it in the usual way:
alert(o.propertyName);
source share