User Tools

Site Tools


java-script:arrow-function-return-object

Returning an Object from an arrow function

If you want to return the object from the arrow function, you'll need to either use the return keyword:

const getObject = () => {
  return { key: 'value' };
};

Or use parentheses to make it an implicit return of an object literal:

const getObject = () => ({ key: 'value' });
java-script/arrow-function-return-object.txt · Last modified: 2023/08/10 13:43 by odefta