declarative functions

Solutions on MaxInterview for declarative functions by the best coders in the world

showing results for - "declarative functions"
Tommaso
27 Feb 2017
1//Before ES6
2const person = {
3  name: "Taylor",
4  sayHello: function() {
5    return `Hello! My name is ${this.name}.`;
6  }
7};
8
9//With ES6, 
10//You can remove the function keyword and colon altogether
11//when defining functions in objects.
12const person = {
13  name: "Taylor",
14  sayHello() {
15    return `Hello! My name is ${this.name}.`;
16  }
17};