JSFiddle - React, Tailwind, and code Playground
by Sri Vaishnavi
HTML
<div id="show">DYNAMIC VARIABLE CREATION</div>
JavaScript
var Removenull = function(id,configArray,inputPorts,outputPorts){
this.id = id;
this.configArray = configArray;
this.inputPorts = inputPorts;
this.outputPorts = outputPorts;
this.getId = function(){
return this.id;
};
this.setId = function(id){
this.id = id;
};
this.getConfigArray = function(){
return this.configArray;
};
this.setConfigArray = function(configArray){
this.configArray = configArray;
};
this.getInputPorts = function(){
return this.inputPorts;
};
this.setInputPorts = function(inputPorts){
this.inputPorts = inputPorts;
};
this.getOutputPorts = function(){
return this.outputPorts;
};
this.setOutputPorts = function(outputPorts){
this.outputPorts = outputPorts;
};
this.toString = function(){
return this.id ;
};
}
var divId = "Removenull1";
var droppedToolId = "Removenull";
eval("var "+divId+" = new "+droppedToolId+"();");
//Removenull1Obj.setId("idTest");
//alert(Removenull1.getId());
var rn = new Removenull();
rn.setId("id1");
var rn2 = new Removenull();
rn2.setId("id2");
var arr = [];
arr.push(rn);
arr.push(rn2);
arr.push(eval(divId));
alert(arr);
for(a in arr){
var o = (arr[a]);
alert(JSON.stringify(o));
}