
Fix #2068 - Army of Functions Fix #2070 - Typo Fix #2056 - Grammatical Error Fix #2074 - Remove semi-colon after function declaration
23 lines
306 B
Markdown
23 lines
306 B
Markdown
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?
|
|
```
|
|
|