en.javascript.info/1-js/04-object-basics/04-object-methods/4-object-property-this/task.md
MuhammedZakir 0f5b63d86f Restructure the Solution for 'Army of Functions' task and Fix Typos
Fix #2068 - Army of Functions
Fix #2070 - Typo
Fix #2056 - Grammatical Error
Fix #2074 - Remove semi-colon after function declaration
2020-09-04 13:38:41 +05:30

306 B

importance: 5


Using "this" in object literal

Here the function makeUser returns an object.

What is the result of accessing its ref? Why?

function makeUser() {
  return {
    name: "John",
    ref: this
  };
}

let user = makeUser();

alert( user.ref.name ); // What's the result?