You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ch06.asciidoc
+3-3
Original file line number
Diff line number
Diff line change
@@ -295,7 +295,7 @@ We've already covered `get`, which traps property access; and `set`, which traps
295
295
296
296
==== has Trap
297
297
298
-
We ((("proxies", "has trap", id="prox6ht")))((("traps", "has trap", id="t6ht")))can use `handler.has` to conceal any property you want when it comes to the `in` operator. In the `set` trap code samples we prevented changes and even access to properties with a certain prefix, but unwanted accessors could still probe the `proxy` to figure out whether these properties exist. There are three alternatives here:
298
+
We ((("proxies", "has trap", id="prox6ht")))((("traps", "has trap", id="t6ht")))((("has trap", id="ht6")))can use `handler.has` to conceal any property you want when it comes to the `in` operator. In the `set` trap code samples we prevented changes and even access to properties with a certain prefix, but unwanted accessors could still probe the `proxy` to figure out whether these properties exist. There are three alternatives here:
299
299
300
300
- Do nothing, in which case `key in proxy` falls through to `Reflect.has(target, key)`, the equivalent of `key in target`
301
301
- Return `true` or `false` regardless of whether `key` is or is not present in `target`
The `getOwnPropertyDescriptor` trap in <<getownpropertydescriptor_trap>> offers a ((("proxies", "has trap", startref="prox6ht")))((("traps", "has trap", startref="t6ht")))solution that's able to intercept `Object#hasOwnProperty` as well.
363
+
The `getOwnPropertyDescriptor` trap in <<getownpropertydescriptor_trap>> offers a ((("proxies", "has trap", startref="prox6ht")))((("traps", "has trap", startref="t6ht")))((("has trap", startref="ht6")))solution that's able to intercept `Object#hasOwnProperty` as well.
364
364
365
365
==== deleteProperty Trap
366
366
367
-
Setting a property to `undefined` clears its value, but the property is still part of the object. Using the `delete` operator on a property with code like `delete cat.furBall` means that the `furBall` property will be completely gone from the `cat` object.
367
+
Setting ((("proxies", "deleteProperty trap", id="prox6dpt")))((("traps", "deleteProperty trap", id="trap6dpt")))a property to `undefined` clears its value, but the property is still part of the object. Using the `delete` operator on a property with code like `delete cat.furBall` means that the `furBall` property will be completely gone from the `cat` object.
0 commit comments