JSFiddle - React, Tailwind, and code Playground
method chaining example
JavaScript
class Calc {
constructor(value=0) {
this.value = value;
}
add(x) {
this.value += x;
return this;
}
sub(x) {
this.value -= x;
return this;
}
mul(x) {
this.value *= x;
return this;
}
div(x) {
this.value /= x;
return this;
}
}
let calc = new Calc(2);
console.log(calc.add(3).sub(1).mul(3).div(6).value);