Sobes.tech
Junior — Senior

How does this affect the properties and functions of an object

livecode

Task condition

Determine what data will be output to the console when accessing different fields and methods of an object that uses this.

const obj = {
  a: 1,
  b: this.a + 1,
  c: () => this.a + 1,
  d() {
    return this.a + 1;
  },
  e() {
    return (() => this.a + 1)();
  }
};

console.log(obj.b);
console.log(obj.c());
console.log(obj.d());
console.log(obj.e());