Replace Node.JS
with Node.js
This commit is contained in:
parent
b9ca311f19
commit
735880d45f
12 changed files with 17 additions and 17 deletions
|
@ -37,7 +37,7 @@ let f = user.sayHi;
|
|||
setTimeout(f, 1000); // lost user context
|
||||
```
|
||||
|
||||
The method `setTimeout` in-browser is a little special: it sets `this=window` for the function call (for Node.JS, `this` becomes the timer object, but doesn't really matter here). So for `this.firstName` it tries to get `window.firstName`, which does not exist. In other similar cases as we'll see, usually `this` just becomes `undefined`.
|
||||
The method `setTimeout` in-browser is a little special: it sets `this=window` for the function call (for Node.js, `this` becomes the timer object, but doesn't really matter here). So for `this.firstName` it tries to get `window.firstName`, which does not exist. In other similar cases as we'll see, usually `this` just becomes `undefined`.
|
||||
|
||||
The task is quite typical -- we want to pass an object method somewhere else (here -- to the scheduler) where it will be called. How to make sure that it will be called in the right context?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue