class Calculator {
constructor(value) {
this.value = value;
}
add(num) {
this.value += num;
return this;
}
multiply(num) {
this.value *= num;
return this;
}
}
const calc = new Calculator(5);
const addMethod = calc.add;
const result = addMethod.call(calc, 3).multiply(2);
console.log(result.value); Post #2943
3.33K
CHALLENGE
- 🔥 8
- ❤ 6
- 👍 5