将 Array.some() 与 Karma 和 PhantomJS 一起使用的意外标记 '>'

Unexpected token '>' Using Array.some() With Karma and PhantomJS

我收到以下错误:

PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
   SyntaxError: Unexpected token '>'
   at myAngularControllerPath.js:9

导航到该文件,我发现我正在使用 Array.some() 函数,如下所示:

return list.some(x => isListItemGood(x));

当我 运行 Karma 与 karma.conf.js 文件中指定的 Chrome 时,我没有收到此错误。

根据http://kangax.github.io/compat-table/es5/ , PhantomJS support all 10 new array features of ES5 and Array.some() was introduced in ES5 according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some。我使用 'npm install --save-dev karma-phantomjs-launcher' 安装了 PhantomJS,它在其依赖项中将 2.1.7 列为 PhantomJS 版本。

感谢您的所有帮助!

"Arrow functions" are not supported by PhantomJS 2.x

PhantomJS 只支持 ES6 的一小部分。