ambuli
asked on
Calling objects based on string type in javascript
I have the following code snippet where I want to invoke commands on different objects based on the type given.
How can I do this object oriented way in JavaScript.
How can I do this object oriented way in JavaScript.
function(reportTye){
if( reportType == "REPORT_ONE"){
rep1Cmd = new ReportOne();
rep1Cmd .run();
} else if( reportType == "REPORT_TWO"){
rep2Cmd = new ReportTwo();
rep2Cmd .run();
} else if( reportType == "REPORT_THREE"){
rep3Cmd = new ReportThree();
rep3Cmd .run();
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER