how to make arrow functions as object methods code example
Example 1: javascript return object in arrow function
const func = () => ({ foo: "bar" });
console.log(func()); // { foo: "bar" }
Example 2: how to make arrow functions as object methods
var chopper = {
owner: 'Zed',
getOwner: function() {
return this.owner;
}
};
// or
var chopper = {
owner: 'Zed',
getOwner() {
return this.owner;
}
};