链式调用
Sunny-117 opened this issue · comments
链式调用
const count = {
value:0,
add:function(newValue){
this.value += newValue;
return this;
},
del:function(newValue){
this.value -= newValue;
return this;
}
}
let obj = {
value: 1,
increment: function () {
this.value += 1;
return this;
},
add: function (v) {
this.value += v;
return this;
},
shout: function () {
console.log(this.value);
return this;
}
};
obj.increment().add(3).shout(); // 输出:5