我想改造这段代码:
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'));
I get expression expected
箭头处有语法错误。我抬头默认语法在这里 https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Shorter_functions看起来我的代码的语法是正确的。有什么想法可能是什么问题吗?
我让它使用以下语法:
var quoteAmounts = res.transactions.map(function (tx) {
return Currency.toSmallestSubunit(tx.usd, 'USD')
});
但我想让它成为一个带有箭头功能的单行代码。
运行于node v5.3.0
我有错误expression expected
报道者Webstorm编辑 Node.js 程序时。在这种情况下,解决方案是将语言版本设置为支持此功能的版本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)