链模式
promise就是一个典型的链模式,每次调用都返回this用于下一次调用自身的方法。
function Person() {
this.run = function() {
console.log('running')
return this
}
this.walk = function() {
console.log('walking')
return this
}
}
let p = new Person()
p.run().walk().run()