javascript - Setting object property with bracket notation inside object literal -
so have lengthy object literal many properties , methods, in simple following form no explicit instantiation:
var my_object = { prop1:"a", method1:function() {console.log("foo");} };
one of these object methods receives data internet in form xml http request , runs following bit of code:
$.each(xmlobj,function(k,v) { this["to_"+k] = v; this["to_"+k+"_color"] = func1(v); this["to_"+k+"_symbols"] = func2(v); });
i've checked , returned data exists , in format expect, problem i'm having bracket notation not work here assign new properties this
(my_object). console.log(my_object)
confirms these new properties not assigned.
so there way work around bracket notation's failure assign new properties here, or going stuck writing out dozens of dot notation assignments?
Comments
Post a Comment