handler.has()
The handler.has()
method is a trap for the in
operator.
Syntax
new Proxy(target, {
has(target, prop) {
}
});
Parameters
The following parameters are passed to has()
method. this
is
bound to the handler.
target
- : The target object.
prop
- : The name or
Symbol
of the property to check for existence.
- : The name or
Return value
The has()
method must return a boolean value.
Description
The handler.has()
method is a trap for the in
operator.
Interceptions
This trap can intercept these operations:
- The
in
operator:foo in proxy
with
check:with(proxy) { (foo); }
Reflect.has()
Or any other operation that invokes the [[HasProperty]]
internal method.
Invariants
If the following invariants are violated, the trap throws a TypeError
when invoked.
- A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.
- A property cannot be reported as non-existent, if it exists as an own property of the target object and the target object is not extensible.