this в JS
let user = {
name: "Gizmo",
ref: this,
};
// Выведет undefined или Window{...}
console.log(user.ref);let user = {
name: "Gizmo",
ref: function (){
return this;
},
};
// Выведет {name: "Gizmo", ref: function}
console.log(user.ref());Last updated