首页 > 代码库 > as3的操作符重载

as3的操作符重载

Array.prototype.valueOf = function ():Number
{
      var sum:Number = 0;
      for each (var v:* in this)
      {
              if (v is Number)
              {
                     sum += v;
              }
       }
       return sum;
};
trace( [1,2,3, 7] + [3,2,1] + [5,3,2] ); // Yeah! 29 output

 

转自

http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/

as3的操作符重载