0
const foo = () => {
  return {
    name: 'Alex',
    age: '24',
  };
};

const bar = () => ({
  name: 'Alex',
  age: '24',
});

console.log(foo()) // {name: 'Alex', age: '24'}
console.log(bar()) // {name: 'Alex', age: '24'}

As i understand, if i need a function just for return an object, i can use a second syntax (without return) ?

  • Your understanding is correct (and the parentheses around the object literal are important syntax). – jsejcksn Nov 28 '22 at 19:02

0 Answers0