比如
function abc(){
}
var obj=new abc(1,2,4);
alert(obj),现在弹出[object,Object], 我怎么让obj编程一个数字或字符串,比如说1+2+4的结果7?
function abc(){
}
var obj=new abc(1,2,4);
alert(obj),现在弹出[object,Object], 我怎么让obj编程一个数字或字符串,比如说1+2+4的结果7?
调试欢乐多
function abc(a, b, c) {
this.result = a + b + c;
}
var obj = new abc(1,2,4);
alert(obj.result);
//函数
function abcd(a, b, c, d) { return a + b + c + d; }
alert(abcd(1,2,3,4));
哦 合着是Array用的也是obj.toString()方法,而这个toString()省略掉了,是这样吗?
重写下toString 就O了。