Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 421 Bytes

no-proxy.md

File metadata and controls

24 lines (19 loc) · 421 Bytes

Forbid the use of Proxy

Proxies add a hidden layer of side-effects when accessing properties of objects or elements of arrays.

Fail

const handler = {
  get(target, key) {
    return Math.min(target[key], 0);
  }
};
const object = new Proxy(variable, handler);
object.a;

Pass

function positiveProperty(target, key) {
  return Math.min(target[key], 0);
}
positiveProperty(object, 'a');