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/

posted on 2014-12-17 15:26  jiahuafu  阅读(274)  评论(0编辑  收藏  举报

导航