خرید بک لینک

Vote count: 0

How could I call the class function from its string?

After I check if the function exists

if(typeof requestName == 'function') {

 }

I need to call the class function, for example CreateJob inside class Foo. How could I do this?

var Foo = function(credentialsObject){
        this.cred = credentialsObject;
    };

    Foo.prototype.SendRequest = function(requestName,dataObj) {
        // If create requestName, job object exists and credentials have been setup, proceed with a requestName call
        if(requestName && dataObj && (this.cred.userID && this.cred.apiKey)) {
            // Check if the function exists
           if(typeof requestName == 'function') {

           }
        }
    };

    Foo.prototype.CreateJob = function(dataObj) {

    };

    Foo.prototype.CancelJob = function(dataObj) {

    };

    Foo.prototype.JobStatus = function(dataObj) {

    };

asked 2 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 13 اسفند 1394 ساعت: 14:06

صفحه بندی