SO I have a JS object that looks something like..
var Monitor=function(parent,params={}){
this.parent=null;
this.canvas=null;
this.width=600;
this.height=400;
this.backColor="#252525";
this.lineColor="#0171a7";
this.lineWidth=4;
this.radius=3;
/* 2017-12-31 **********************************
Innitialize the monitor class
***********************************************/
this.init=function(parent,params){
var that=this;
this.parent=parent;
//Loop through params and set them.
$.each(params,function(i,val){
eval("that."+i+"="+val);
})
return this;
};
this.init(parent,params);
}
and call it with...
mc=new Monitor(
$("#monitors"),
{
"width":800;
"height":600,
}
);
I want to set the properties dynamically in a loop.
However, to get it to work, I have to use eval (Eval is evil... right?). So it there a better way to set properties dynamically?