ECMAScript 6 arrow function that returns an object

后端 未结 6 2141
花落未央
花落未央 2020-11-21 05:24

When returning an object from an arrow function, it seems that it is necessary to use an extra set of {} and a return keyword because of an ambigui

6条回答
  •  天涯浪人
    2020-11-21 05:44

    You can always check this out for more custom solutions:

    x => ({}[x.name] = x);
    

提交回复
热议问题