You pass callback at first argument baz, so you can call it like this:(您在第一个参数baz处传递了回调,因此可以这样调用它:)
class WorkHard { constructor() { this.value_1 = [] this.value_2 = [] } foo(args) { this.value_1 = args; return this; } baz(cb) { this.value_1 = null; this.value_2 = null; cb(); return this; } zoo(args) { this.value_2 = args; return this; } } const workHard = new WorkHard(); workHard .foo('TestValue_1') .baz(() => { console.log('This is baz() method content.'); }) .zoo('TestValue_2');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…