我想转换这段代码:
var formatQuoteAmount = function (tx) {
return Currency.toSmallestSubunit(tx.usd, 'USD');
};
var quoteAmounts = res.transactions.map(formatQuoteAmount);
变成匿名箭头函数。我写了这个:
var quoteAmounts = res.transactions.map(tx => Currency.toSmallestSubunit(tx.usd, 'USD'));
我在箭头处得到 expression expected
语法错误。我 在这里查看了默认语法,似乎我的代码语法是正确的。任何想法可能是什么问题?
我让它使用这种语法:
var quoteAmounts = res.transactions.map(function (tx) {
return Currency.toSmallestSubunit(tx.usd, 'USD')
});
但我想让它成为一个带有箭头功能的单线。
运行于 node v5.3.0
原文由 Milkncookiez 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在编辑 Node.js 程序时遇到 Webstorm 报告的错误
expression expected
。在这种情况下,解决方案是将语言版本设置为支持此功能的版本。