Clarity for this
A more ideal explanation of `this` assigning
This commit is contained in:
parent
b2559f4d39
commit
cb26b559bb
1 changed files with 2 additions and 2 deletions
|
@ -154,8 +154,8 @@ let user = { name: "John" };
|
|||
let admin = { name: "Admin" };
|
||||
|
||||
// use call to pass different objects as "this"
|
||||
sayHi.call( user ); // John
|
||||
sayHi.call( admin ); // Admin
|
||||
sayHi.call( user ); // this = John
|
||||
sayHi.call( admin ); // this = Admin
|
||||
```
|
||||
|
||||
And here we use `call` to call `say` with the given context and phrase:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue