function makeUser() {
return {
name: "John",
ref() {
return this;
}
};
}
let user = makeUser();
alert(user.ref().name);
From what I've learned from thistutorial, they define as the object before dot and since this is the return value of the function, I thought it would be user.
And this tutorial is defining it as the object that is executing the current function.
I think the object that is executing the current function is user. When you replace this by its value it becomes alert(user.user.name);
.