Skip to main content
Version: 3.27.2

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.

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:

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.