js object methods es6 code example
Example: es6 method definition syntax
const obj = {
foo() {
return 'bar';
}
};
console.log(obj.foo());
// expected output: "bar"
const obj = {
foo() {
return 'bar';
}
};
console.log(obj.foo());
// expected output: "bar"