Can the following javascript code written shorter? It creates a wrapper object with the id property as key and the element itself as value.
const f = elem => {
return {[elem.id]: elem}
}
Sample:
f({id:'node/1', value:'tmp'})
Result:
{'node/1': {id:'node/1', value:'tmp'}}
I thought about arrow function style const f = elem => {[elem.id]: elem}
, but Chrome didn't want it.