I know this a weird question, but I'll ask it anyway.
The pseudo code function below provides a virtual property getter. What it should do is this:
> const calc = Calculator(3)
> calc.multiple // returns getter result directly
6
> calc.multiple(4) // returns thunk result, thus behaves like a function
12
Here's my pseudo code:
function Calculator(num) {
return {
get multiple() {
if (isFunctionCalled()) { // isFunctionCalled is an
// imaginary function check
return (mult = 3) => {
return mult * num;
};
}
// getter called, default calulation
return 2 * num;
},
};
}