Is there a way to make the following javascript code more concise? It creates an object with the element's id as key and the element itself as value.
const createWrapper = elem => {
return {[elem.id]: elem}
}
Example:
createWrapper({id:'node/1', value:'tmp'})
Output:
{'node/1': {id:'node/1', value:'tmp'}}
I initially considered using arrow function style
const createWrapper = elem => {[elem.id]: elem}
, but there were compatibility issues in Chrome.