JS - Array function is not suit for object method

21 Sep 2020

var person = {
  name: 'John',
  hi: function() {
    console.log(`Hi, I'm ${this.name}`)
  }
}

Output: “Hi, I’m John”

var person = {
  name: 'John',
  hi: () => {
    console.log(`Hi, I'm ${this.name}`)
  }
}

Output: “HI, I’m”

The result is very simple. array function is not suit for object method.

Back to top