Proxy traps

There are different traps for the different operations that can be performed on an object. Some of the traps need to return values. There are some rules you need to follow when returning values. The returned values are intercepted by the proxy to filter and/or check if the returned values obey the rules. If a trap doesn't obey rules while returning a value, then the proxy throws the TypeError exception.

The value of this inside a trap is always a reference to the handler.

Let's take a look at the various kinds of traps.

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.