❗arrow function returning object literal needs (...)❗️
🚧 under construction
const user = () => { age: 2019 }; // ❌
const user = () => ({ age: 2019 }); // ✅ const user = () => { name: 'Gandalf', age: 2019 };const user = () => {
name: 'Gandalf', age: 2019
// ↳ ⛔️ SyntaxError: Unexpected token ':'
};// ⭐️ wrap object literal in parentheses
const user = () => ({
name: 'Gandalf',
age: 2019
});
console.log(user()); // { name: 'Gandalf', age: 2019 }Last updated