---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Proxy()

The **`Proxy()`** constructor is used to create `Proxy` objects.

## Syntax

```js
new Proxy(target, handler)
```

> **Note:** `Proxy()` can only be constructed with `new`. Attempting to call it without `new` throws a [`TypeError`](../../globals/TypeError/TypeError.mdx).

### Parameters

- `target`
  - : A target object to wrap with `Proxy`. It can be any sort of object,
    including a native array, a function, or even another proxy.
- `handler`
  - : An object whose properties are functions that define the behavior of the proxy when
    an operation is performed on it.

## Description

Use the `Proxy()` constructor to create a new `Proxy` object.
This constructor takes two mandatory arguments:

- `target` is the object for which you want to create the proxy
- `handler` is the object that defines the custom behavior of the proxy.

An empty handler will create a proxy that behaves, in almost all respects, exactly like
the target. By defining any of a set group of functions on the `handler`
object, you can customize specific aspects of the proxy's behavior. For example, by
defining `get()` you can provide a customized version of the target's
[property accessor](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Property_Accessors).

### Handler functions

This section lists all the handler functions you can define. Handler functions are
sometimes called _traps_, because they trap calls to the underlying target
object.

- [`handler.apply()`](../../globals/Proxy/proxy/apply.mdx)
  - : A trap for a function call.
- [`handler.construct()`](../../globals/Proxy/proxy/construct.mdx)
  - : A trap for the `new` operator.
- [`handler.defineProperty()`](../../globals/Proxy/proxy/defineProperty.mdx)
  - : A trap for [`Object.defineProperty`](../../globals/Object/defineProperty.mdx).
- [`handler.deleteProperty()`](../../globals/Proxy/proxy/deleteProperty.mdx)
  - : A trap for the `delete` operator.
- [`handler.get()`](../../globals/Proxy/proxy/get.mdx)
  - : A trap for getting property values.
- [`handler.getOwnPropertyDescriptor()`)}](../../globals/Proxy/proxy/getOwnPropertyDescriptor.mdx)
  - : A trap for [`Object.getOwnPropertyDescriptor`](../../globals/Object/getOwnPropertyDescriptor.mdx).
- [`handler.getPrototypeOf()`](../../globals/Proxy/proxy/getPrototypeOf.mdx)
  - : A trap for [`Object.getPrototypeOf()`](../../globals/Object/getPrototypeOf.mdx).
- [`handler.has()`](../../globals/Proxy/proxy/has.mdx)
  - : A trap for the `in` operator.
- [`handler.isExtensible()`](../../globals/Proxy/proxy/isExtensible.mdx)
  - : A trap for [`Object.isExtensible()`](../../globals/Object/isExtensible.mdx).
- [`handler.ownKeys()`](../../globals/Proxy/proxy/ownKeys.mdx)
  - : A trap for [`Object.getOwnPropertyNames()`](../../globals/Object/getOwnPropertyNames.mdx) and
    [`Object.getOwnPropertySymbols()`](../../globals/Object/getOwnPropertySymbols.mdx).
- [`handler.preventExtensions()`)}](../../globals/Proxy/proxy/preventExtensions.mdx)
  - : A trap for [`Object.preventExtensions()`](../../globals/Object/preventExtensions.mdx).
- [`handler.set()`](../../globals/Proxy/proxy/set.mdx)
  - : A trap for setting property values.
- [`handler.setPrototypeOf()`](../../globals/Proxy/proxy/setPrototypeOf.mdx)
  - : A trap for [`Object.setPrototypeOf()`](../../globals/Object/setPrototypeOf.mdx).
