javascript 使用链式结构
var Dog = function(name,color){
this.name=name||"";
this.color=color||"";
};
Dog.prototype.setName = function(name){
this.name = name;
return this;
};
Dog.prototype.setColor = function(color){
this.color=color;
return this;
};
Dog.prototype.yell = function(){
alert(this.name+this.color);
return this;
};
var dog = new Dog();
dog.setName("hhh").setColor("red").yell();