Explain handler method in ES6 Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 3 Likes Like Report A handler is an object whose properties are functions that define the behaviour of the proxy when an operation is performed on it. 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 behaviour. For example, by defining get() you can provide a customized version of the target's property accessor. Syntax: new Proxy(target, handler) proxy constructor(): Used to create a proxy object which takes two parameters. Parameters: target: 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 behaviour of the proxy when an operation is performed on it. List of Handler Methods: This section lists all the handler methods you can define. Handler methods are sometimes called traps, because they trap calls to the underlying target object handler.apply(): A trap for a function call.handler.construct(): A trap for the new operator.handler.defineProperty(): A trap for Object.defineProperty.handler.deleteProperty(): A trap for the delete operator.handler.get(): A trap for getting property values.handler.getOwnPropertyDescriptor(): A trap for Object.getOwnPropertyDescriptor.handler.getPrototypeOf(): A trap for Object.getPrototypeOf.handler.has(): A trap for the in operator.handler.isExtensible(): A trap for Object.isExtensible.handler.ownKeys(): A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.handler.preventExtensions(): A trap for Object.preventExtensions.handler.set(): A trap for setting property values.handler.setPrototypeOf(): A trap for Object.setPrototypeOf. Example: In this example, the target has two properties, string and num. We define a handler that returns a different value for num, and lets any other accesses through to the target. JavaScript <script> const target = { string: "GeeksForGeeks", num: 123 }; const handler = { get: function (target, prop, receiver) { if (prop === "string") { return "GeeksForGeeks"; } return Reflect.get(...arguments); } }; const obj = new Proxy(target, handler); console.log(obj.string); // "GeeksForGeeks" console.log(obj.num); // "123" </script> Output: GeeksForGeeks 123 Create Quiz Comment D devendrasalunke Follow 3 Improve D devendrasalunke Follow 3 Improve Article Tags : JavaScript Web Technologies ES6 JavaScript-Questions Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like