Saturday, 15 April 2017

Object destructuring - How to rewrite this function in a shorter way?

I am using babel and ES6, I would like to know if it is possible to write the following code in a shorter way, specially I do not like the manual remap pf property in the return statement.

  const locations = action.payload.list.map(location => {
    return {
      id: location.id,
      name: location.name,
      country: location.sys.country
    }
  })



via Radex

No comments:

Post a Comment