I wanted to return an object from an arrow function, but the code below was returning undefined
. I realized that the curly braces were being interpreted as beginning/ending the function body. What intrigues me is why a: 1
didn’t throw an error.
const foo = () => {a: 1};
foo();
// > undefined