Skip to content

Commit a8acaf9

Browse files
committed
Edited ch06.asciidoc with Atlas code editor
1 parent ad1fdfc commit a8acaf9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ch06.asciidoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ function invariant(key, action) {
651651
const target = {}
652652
const proxy = new Proxy(target, handler)
653653
Reflect.getOwnPropertyDescriptor(proxy, '_secret')
654-
// <- Error: Can't get property descriptor for private "_secret" property
654+
// <- Error: Can't get property descriptor for private
655+
// "_secret" property
655656
----
656657

657658
One problem with this approach might be that you're effectively telling external consumers that they're unauthorized to access prefixed properties. It might be best to conceal them entirely by returning `undefined`. That way, private properties will behave no differently than properties that are truly absent from the `target` object. The following example shows how `Object.getOwnPropertyDescriptor` returns `undefined` for an nonexistent `dressing` property, and how it does the same for a `_secret` property. Existing properties that aren't in the private property space produce their property descriptors as usual.

0 commit comments

Comments
 (0)