| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Corrected a section of the writeup on 'Step into' command pertaining to beginners. Instead of "as we don't have asynchronous calls yet", I suggest the words to be "as we haven't learnt about asynchronous calls yet". The former suggests that Javascript lacks the ability to make asynchronous calls, which is not the case, in my opinion.
There was a problem hiding this comment.
Here are some automated review suggestions for this pull request.
Reviewed commit: d3e1443ba7
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
| As demonstrated in the chapter <info:bind> functions in JavaScript have a dynamic `this`. It depends on the context of the call. | ||
|
|
||
| So if an object method is passed around and called in another context, `this` won't be a reference to its object any more. | ||
| Recall the **"losing `this`"** problem from the chapter <info:bind>. Functions in JavaScript have a dynamic `this` — it depends on how the function is called, not where it's defined. So, when an object method is passed around (e.g. as a callback to `setTimeout`, or as an event handler), `this` no longer points to the original object. |
There was a problem hiding this comment.
Qualify the call-site this rule
This newly added explanation is false for arrow functions: their this is lexical and therefore does depend on where they are defined. That distinction is essential here because the solution immediately below uses click = () => ... precisely to capture the instance's this; saying that JavaScript functions universally use call-site this makes the explanation contradict its own example. Please limit this rule to regular functions or methods.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
|
Codex seems to have skipped the method vs function distinction in my writeup! To clarify things, I clearly wrote the following in my writeup: Making methods bound to object instances using class fields is a third solution. Such methods, called "bound methods" can be created with a very elegant syntax, The intention is to convey to the reader that this third solution is applicable only to methods, not to functions in general. Also, the original wirteup made no clarification as to what it meant by "bound methods". My writeup makes it explicit, making it easier for the reader to understand what the article intends to convey. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This pull request make the following improvements in the literature: