es6 functions equivalent code example
Example 1: es6 method definition syntax
const obj = {
foo() {
return 'bar';
}
};
console.log(obj.foo());
// expected output: "bar"
Example 2: es6 class example
var Polygon = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
}