0
function Pet(name) {
  this.name = name;
  this.getName = () => this.name;
}
const cat = new Pet('Fluffy');

const { getName } = cat;
console.log(getName());

In the code above, why does getName prints "Fluffy"? It is executed in the global context. Why does value of this still references Pet?

0 Answers0