原理很简单每次执行完函数返回this
直接上代码
function test(){
this.name;
this.age;
}
test.prototype.testChild=function(){
this.name="demo"
return this
}
test.prototype.testChild2=function(){
this.age=20
return this.name+":"+this.age
}
var a=new test()
var b=a.testChild().testChild2()
console.log(b)//demo:20