How best to implement out params in JavaScript?

后端 未结 9 1585
盖世英雄少女心
盖世英雄少女心 2020-12-15 03:36

I\'m using Javascript with jQuery. I\'d like to implement out params. In C#, it would look something like this:

/*
 * odp      the object to test
 * error            


        
9条回答
  •  感情败类
    2020-12-15 03:55

    I think this is pretty much the only way (but I am not a hardcore JavaScript programmer ;)).

    What you could also consider is to use a callback function:

    function onError(data) {
        // do stuff
    }
    
    
    function isLegal(odp, cb) {
        //...
        if(error) cb(error);
        return false;
    }
    
    isLegal(value, onError);
    

提交回复
热议问题