Merge pull request #2021 from lumosmind/patch-44
to make binding more clear
This commit is contained in:
commit
f38eb4e1b1
1 changed files with 1 additions and 1 deletions
|
@ -167,7 +167,7 @@ sayHi(); // Hello, John!
|
||||||
setTimeout(sayHi, 1000); // Hello, John!
|
setTimeout(sayHi, 1000); // Hello, John!
|
||||||
|
|
||||||
// even if the value of user changes within 1 second
|
// even if the value of user changes within 1 second
|
||||||
// sayHi uses the pre-bound value
|
// sayHi uses the pre-bound value which is reference to the old user object
|
||||||
user = {
|
user = {
|
||||||
sayHi() { alert("Another user in setTimeout!"); }
|
sayHi() { alert("Another user in setTimeout!"); }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue