class ValueHolder {
#value;
get value() {return this.#value;}
set value(v) {this.#value = v;}
}
const holder = new ValueHolder();
function getValue1(x) {
return holder.value;
}
function wrappedValue1(x) { return getValue1(x); }
function getValue2(x, anyHolder=holder) {
return anyHolder.value;
}
function wrappedValue2(x) { return getValue2(x); }
function getValue3(x, anyHolder=holder) {
const propName = "value";
return anyHolder[propName];
}
function wrappedValue3(x) { return getValue3(x); }
function getValue4(x, anyHolder=holder, propName="value") {
return anyHolder[propName];
}
function wrappedValue4(x) { return getValue1(4); }
function benchmark(func) {
let x;
for (let i = 0; i < 1000000; i++) {
x = func(i);
}
return x;
}