Proxies add a hidden layer of side-effects when accessing properties of objects or elements of arrays.
const handler = {
get(target, key) {
return Math.min(target[key], 0);
}
};
const object = new Proxy(variable, handler);
object.a;
function positiveProperty(target, key) {
return Math.min(target[key], 0);
}
positiveProperty(object, 'a');