From JSON, I want to request the name of a constructor and have it execute in javascript.
json.js
{
objArray = [
{
"funcName":"executeMe"
}
]
}
page.js
var newInstance = createInstanceByName(objArray[0].funcName); //"executeMe"
//Functions like: var newInstance = new lib.executeMe();
lib.js (I have no control over) looks like this:
(lib.executeMe = function() {
this.initialize(img.executeMe);
}).prototype = new cjs.Bitmap();
p.nominalBounds = new cjs.Rectangle(0,0,200,200);
I was hoping I could repurpose the solution from this thread but it's important that the variable newInstance is available to me throughout page.js - it's not enough to have me pass it the context. I need the assignment to happen here.
How could createInstanceByName() work?