87,914
社区成员
发帖
与我相关
我的任务
分享
Test.sum=function(a,b)
{return new Test(this.A + a, this.B + b); }
<script type="text/javascript">
function Test(a,b)
{
this.A = a;
this.B = b;
}
/*定义一个函数sum,分别给属性A、B加上a、b的值*/
Test.sum= function(a,b)
{
return new Test(this.A + a, this.B + b);
}
Test.prototype.update = function(a,b)
{
return new Test(a,b);
}
function hee(){
var test = new Test(1,2);
test.sum(1,2);//test.A == 2,test.B == 4
test.update(1,2);
}
</script>