Answers for "Declarative Functions"

0

Declarative Functions

//Before ES6
const person = {
  name: "Taylor",
  sayHello: function() {
    return `Hello! My name is ${this.name}.`;
  }
};

//With ES6, 
//You can remove the function keyword and colon altogether
//when defining functions in objects.
const person = {
  name: "Taylor",
  sayHello() {
    return `Hello! My name is ${this.name}.`;
  }
};
Posted by: Guest on January-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language