I've summerized my problem in an example below, the problems is, if I use in an object an arrow function with only one item (23
) in the function (as below), I've to not to use curly brackets for it to work. Why is so? I thought it was optional not to use curly brackets when in the function there is only one item. Thanks
Doesn't work with curly brackets, returns
undefined
obj = { y: () => {23} } console.log(obj.y());
Works without curly brackets, returns
23
obj = { x: () => 23 } console.log(obj.x());`
"to work with or without the curly brackets"