---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# handler.has()

The **`handler.has()`** method is a trap for the `in` operator.

## Syntax

```js
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:

- The [`in`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/in) operator: `foo in proxy`
- [`with`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/with) check: `with(proxy) { (foo); }`
- [`Reflect.has()`](../../../globals/Reflect/has.mdx)

Or any other operation that invokes the `[[HasProperty]]` [internal method](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy#object_internal_methods).

### Invariants

If the following invariants are violated, the trap throws a [`TypeError`](../../../globals/TypeError/TypeError.mdx) 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.
