日期:2014-05-16 浏览次数:20418 次
function people(a,b,c){
this.name = a;
this.age = b;
this.sex = c;
this.toString = function(){
return this.name + this.age + this + sex;
}
}
function people(a,b,c){
this.name = a;
this.age = b;
this.sex = c;
}
people.prototype.toString=function(){ return this.name + this.age + this + sex; }
function people(a,b,c){
this.name = a;
this.age = b;
this.sex = c;
}
var a = new people(1,2,3);
console.log(a.toString());
//使用的Object中的toString方法
function people1(a,b,c){
this.name = a;
this.age = b;
this.sex = c;
this.toString = function(){
return this.name + this.age + this.sex;
}
}
var b = new people1(4,5,6);
console.log(b.toString());
//使用的自己重现定义的新方法
return this.name + this.age + this + sex;