es6 function definition code example
Example 1: es6 method definition syntax
const obj = {
foo() {
return 'bar';
}
};
console.log(obj.foo());
// expected output: "bar"
Example 2: es6 functions
const add = (n1, n2) => n1 + n2
const obj = {
foo() {
return 'bar';
}
};
console.log(obj.foo());
// expected output: "bar"
const add = (n1, n2) => n1 + n2