164 views
How does the value of this change when a method is detached from an object
Task condition
Determine what will be output to the console after calling the function fn().
const obj = {
a: 1,
show(num) {
if (num !== undefined) {
console.log(this.a + num);
return;
}
console.log(this.a);
},
};
const fn = obj.show;
fn();