ES6 Classes & Constructors
What programming pattern is demonstrated by the Calculator class?
class Calculator {
constructor() {
this.value = 0;
}
add(a) {
this.value += a;
return this;
}
subtract(a) {
this.value -= a;
return this;
}
getValue() {
return this.value;
}
}