Skip to content

Commit eec460d

Browse files
author
wendy@lastlookeditorial.com
committed
Edited ch06.asciidoc with Atlas code editor
1 parent 43a5e5f commit eec460d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ch06.asciidoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ We've already covered `get`, which traps property access; and `set`, which traps
295295

296296
==== has Trap
297297

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:
299299

300300
- Do nothing, in which case `key in proxy` falls through to `Reflect.has(target, key)`, the equivalent of `key in target`
301301
- Return `true` or `false` regardless of whether `key` is or is not present in `target`
@@ -360,11 +360,11 @@ console.log(proxy.hasOwnProperty('_secret'))
360360
// <- true
361361
----
362362

363-
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.
364364

365365
==== deleteProperty Trap
366366

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.
368368

369369
[source,javascript]
370370
----

0 commit comments

Comments
 (0)