Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch3: fix typo in Object.setPrototypeOf() perf note #63

Merged
merged 1 commit into from
Jun 9, 2018
Merged

ch3: fix typo in Object.setPrototypeOf() perf note #63

merged 1 commit into from
Jun 9, 2018

Conversation

vsemozhetbyt
Copy link
Contributor

`obj.__proto__ = …` -> `Object.setPrototypeOf(...)`.

Sync it with the first sidebar paragraph and the source.

@vsemozhetbyt
Copy link
Contributor Author

Closing as it seems this repo does not accept PRs anymore.

@vsemozhetbyt vsemozhetbyt deleted the ch3-obj-set-prototype-of-typo branch June 9, 2018 09:25
@bevacqua
Copy link
Member

bevacqua commented Jun 9, 2018

It does, just took me a bit to get back to them

@vsemozhetbyt vsemozhetbyt restored the ch3-obj-set-prototype-of-typo branch June 9, 2018 18:48
@vsemozhetbyt vsemozhetbyt reopened this Jun 9, 2018
ch03.asciidoc Outdated
@@ -877,7 +877,7 @@ Using `Object.setPrototypeOf` to change the prototype of an object is an expensi

[quote, Mozilla Developer Network]
____
Changing the prototype of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation, in every browser and JavaScript engine. The effects on performance of altering inheritance are subtle and far-flung, and are not limited to simply the time spent in a `obj.__proto__ = …` statement, but may extend to any code that has access to any object whose prototype has been altered. If you care about performance you should avoid setting the prototype of an object. Instead, create a new ((("objects", "built-in improvements", startref="ob3bii")))object with the desired ((("objects", "setting prototypes", startref="ob3sp")))((("Object.setPrototypeOf", startref="ospo3")))prototype using `Object.create()`.
Changing the prototype of an object is, by the nature of how modern JavaScript engines optimize property accesses, a very slow operation, in every browser and JavaScript engine. The effects on performance of altering inheritance are subtle and far-flung, and are not limited to simply the time spent in a `Object.setPrototypeOf(...)` statement, but may extend to any code that has access to any object whose prototype has been altered. If you care about performance you should avoid setting the prototype of an object. Instead, create a new ((("objects", "built-in improvements", startref="ob3bii")))object with the desired ((("objects", "setting prototypes", startref="ob3sp")))((("Object.setPrototypeOf", startref="ospo3")))prototype using `Object.create()`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use instead of ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done)

@bevacqua bevacqua merged commit c48753b into mjavascript:master Jun 9, 2018
@vsemozhetbyt vsemozhetbyt deleted the ch3-obj-set-prototype-of-typo branch June 9, 2018 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants