Reputation: 2109
For example:
alert([3,5].map(v=>{v:v}));
It thinks v:v is a function but I want it to be json. Is this possible?
Upvotes: 0
Views: 239
Reputation: 68923
Wrap {v:v} with parenthesis.
{v:v}
console.log([3,5].map(v=>({v:v})));
Upvotes: 1