鏈模式
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()