up
This commit is contained in:
parent
5372c18379
commit
3defacc09d
314 changed files with 1761 additions and 1704 deletions
|
@ -0,0 +1,23 @@
|
|||
importance: 5
|
||||
|
||||
---
|
||||
|
||||
# Using "this" in object literal
|
||||
|
||||
Here the function `makeUser` returns an object.
|
||||
|
||||
What is the result of accessing its `ref`? Why?
|
||||
|
||||
```js
|
||||
function makeUser() {
|
||||
return {
|
||||
name: "John",
|
||||
ref: this
|
||||
};
|
||||
};
|
||||
|
||||
let user = makeUser();
|
||||
|
||||
alert( user.ref.name ); // What's the result?
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue