I recently switched to es6 and started using arrow functions all over my code. While refactoring I came across below code
data.map(function(d) {
return {id: d.id, selected: bool};
});
I changed above code to this -
data.map((d) => {id: d.id, selected: bool});
But I was getting error from above code. I don't know what is wrong here? I know that If there is no block of code then there is implicit return provided by arrow function.
But don't know how to return empty object or anonymous object with some properties initialized ?
Edit:
What is wrong if I do it in this way? Just for curiosity sake.
data.map((d) => new {id: d.id, selected: bool});