Hacker News new | ask | show | jobs
by idbehold 3198 days ago
Yeah, that was my though as well. It seems like what you need is something like:

   const objToArray = Object.entries
   const arrayToObj = (a) => a.reduce((a, [k, v]) => ((a[k]=v), a), {})
   arrayToObj(objToArray({ foo: 'bar' })) // { foo: 'bar' }