Skip to content

Commit 518351f

Browse files
author
wendy@lastlookeditorial.com
committed
Edited ch06.asciidoc with Atlas code editor
1 parent ea05238 commit 518351f

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
@@ -975,11 +975,11 @@ console.log(proxy)
975975
// <- { 0: 'first', 1: 'second', length: 2 }
976976
----
977977

978-
Conversely to the `getPrototypeOf` trap, there's `setPrototypeOf`.
978+
Conversely to the `getPrototypeOf` trap, ((("getPrototypeOf trap", startref="gptot6")))((("traps", "getPrototypeOf", startref="t6gpto")))((("proxies", "getPrototypeOf trap", startref="prox6gptot")))there's `setPrototypeOf`.
979979

980980
==== setPrototypeOf Trap
981981

982-
There is an `Object.setPrototypeOf` method in ES6 that can be used to change the prototype of an object into a reference to another object. It's considered the proper way of setting the prototype, as opposed to setting the special `__proto__` property, which is a feature that's supported in most browsers but was deprecated in ES6.
982+
There is an `Object.setPrototypeOf` ((("setPrototypeOf trap", id="sptot6")))((("traps", "setPrototypeOf", id="t6spto")))((("proxies", "setPrototypeOf trap", id="prox6sptot")))method in ES6 that can be used to change the prototype of an object into a reference to another object. It's considered the proper way of setting the prototype, as opposed to setting the special `__proto__` property, which is a feature that's supported in most browsers but was deprecated in ES6.
983983

984984
Deprecation means that browser vendors are discouraging the use of `__proto__`. In other contexts, deprecation also means that the feature might be removed in the future. The web platform, however, doesn't break backward compatibility, and `__proto__` is unlikely to ever be removed. That being said, deprecation also means you're discouraged from using the feature. Thus, using the `Object.setPrototypeOf` method is preferable to changing `__proto__` when we want to modify the underlying prototype for an object.
985985

@@ -1018,7 +1018,7 @@ proxy.setPrototypeOf(proxy, base)
10181018
// <- Error: Changing the prototype is forbidden
10191019
----
10201020

1021-
In these cases, it's best to fail with an exception so that consumers can understand what is going on. By explicitly disallowing prototype changes, the consumer can start looking elsewhere. If we didn't throw an exception, the consumer could still eventually learn that the prototype isn't changing through debugging. You might as well save them from that pain!
1021+
In these cases, it's best to fail with an exception so that consumers can understand what is going on. By explicitly disallowing prototype changes, the consumer can start looking elsewhere. If we didn't throw an exception, the consumer could still eventually learn that the prototype isn't changing through debugging. You might as well save them ((("setPrototypeOf trap", startref="sptot6")))((("traps", "setPrototypeOf", startref="t6spto")))((("proxies", "setPrototypeOf trap", startref="prox6sptot")))from that pain!
10221022

10231023
==== preventExtensions Trap
10241024

0 commit comments

Comments
 (0)