Arrow Function in Object Literal

by dsandmark

JavaScript

let arrowObject = {
  name: 'arrowObject',
  printName: () => {
    console.log(this);
  }
};

arrowObject.printName();

let functionObject = {
  name: 'functionObject',
  printName: function() {
    console.log(this);
  }
};

functionObject.printName();