FAQ: Advanced Objects - The this Keyword

User error strikes again! Thanks

1 Like

WHY THIS WOULD NOT PRINT ME ANY RESULTS?

const robot = {
  model: '1E78V2',
  energyLevel: 100,
  provideInfo() { 
    console.log(`I am ${this.model} and my current energy level is ${this.energyLevel}.`)
  }
};

It should give you output if you invoke the method after the last closing brace…

robot.provideInfo()