ECMA 6 support in Nashorn

。_饼干妹妹 提交于 2019-12-23 18:31:19

问题


I just tried out Nashorn and it seems not to support Array.prototype.fill. Is this surprising? Is there a timeline somewhere for Nashorn's intended support? Is the best way to get an array of say 5 0s in Nashorn currently Array.apply(null, Array(5)).map(x=>0)?


回答1:


Seems there is partial support for ES6 in Java9 and more coming later: https://www.oracle.com/corporate/features/nashorn-javascript-engine-jdk9.html

Also see: http://openjdk.java.net/jeps/292




回答2:


This documentation would have me believe that you can get ES6 even in Java 8 by using -Dnashorn.args=--language=es6:

https://developer.oracle.com/databases/nashorn-javascript-part2

Indeed, I managed to get some basic ES6 support from Clojure (adding :jvm-opts ["-Dnashorn.args=--language=es6"] to project.clj), though I was still not able to load the library I wanted, so there may indeed still be pieces missing.



来源:https://stackoverflow.com/questions/48038418/ecma-6-support-in-nashorn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!