mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 19:42:37 +02:00
603 B
603 B
title | tags |
---|---|
Returning objects from an arrow function | Javascript |
When using an arrow function in JavaScript, I was expecting to be able to return objects, but ended up with returning undefined
values.
Turns out it's not possible to return directly objects from inside the arrow function because they're confused as statements.
This is covered by MDN.
To return an object, I had to put it inside parenthesis, like this:
latlngs.map(({ lat, lng }) => ({ lat, lng }))