JSFiddle - React, Tailwind, and code Playground

JavaScript

class t {
	constructor() {
    	this.value = 5;
	}
	valueOf() {
    	this.finalMethod();
		return this.value; 
	}
	plus() {
    	this.value++;
		return this;
	}
	minus() {
		this.value--;
		return this;
    }
	finalMethod() {
    	this.value*=this.value;
	}
}

let z = new t();

console.log(+z.plus().plus().minus()) //+ нужен, чтобы привести объект к числу, чтобы он воспользовался своим valueOf
//результат должен быть квадрат числа 5+1+1-1 (36)