Proxy handlers must do what we expect even though we can customize it.
It’s much more pleasant to use it now than ever.
We can also add handler methods to the
handler we pass into the
Proxy constructor or
apply(target, thisArgument, argumentsList) lets us change the behavior of the
It can also change the behavior of direct calls to a function.
target is the target object which we want to control.
thisArgument lets us pass in the value of
this in the function.
argumentsList lets us pass in a list of arguments.
Handler methods have various invariants enforced on them.
They include the following.
apply(target, thisArgument, argumentsList) has no invariants enforced on them.
construct(target, argumentsList, newTarget) must return an object, and not
null or a primitive value.
defineProperty(target, propKey, propDesc) must not let us add [properties to an object that isn’t extensible.
target must have a property must have a non-configurable own property with
configurable are both
false , then we can’t write a new property to the property.
deleteProperty(target, propKey) can’t delete non-configurable own properties of the
get(target, propKey, receiver) must return the property’s value if it has an own, non-writable, and non-configurable data property with name