How best to implement out params in JavaScript?

后端 未结 9 1600
盖世英雄少女心
盖世英雄少女心 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 04:11

    The following is approach i am using. And this is answer for this question. However code has not been tested.

    function mineCoords( an_x1, an_y1 ) {
      this.x1 = an_x1;
      this.y1 = an_y1;
    }
    
    function mineTest( an_in_param1, an_in_param2 ) {
    
      // local variables
      var lo1 = an_in_param1;
      var lo2 = an_in_param2;
    
      // process here lo1 and lo2 and 
      // store result in lo1, lo2
    
      // set result object
      var lo_result = new mineCoords( lo1, lo2 );
      return lo_result;
    }
    
    var lo_test = mineTest( 16.7, 22.4 );
    alert( 'x1 = ' + lo_test.x1.toString() + ', y1 = ' + lo_test.y1.toString() );
    

提交回复
热议问题