class A {
constructor(inval){
this.c = inval;
}
b() {
return this.c + 1;
}
e(z) {
return z+ Math.floor(Math.random()*10);
}
d() {
let x = {
x1: this.b(),
x2: this.e(this.b()),
}
return x;
}
}
var inst = new A(5);
var instret = inst.d();
console.log(instret);
Question: in method d() statement "let x" is it possible to use the x1 property as a argument to x2:this.e() call like this:
let x = {
x1: this.b(),
x2: this.e(x1),
}
tried several combinations none worked. Basically is there a better way than to repeatedly type "this.b()" as parameter to this.e() when what I clearly want as parameter is x1 ?