trinalbadger587
trinalbadger587

Reputation: 2109

Use lambda functions that return json

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

Answers (1)

Mamun
Mamun

Reputation: 68923

Wrap {v:v} with parenthesis.

console.log([3,5].map(v=>({v:v})));

Upvotes: 1

Related Questions