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)
?
-
You always can use transpilers and polyfills :-) – Bergi Dec 30 '17 at 22:39
-
Asking about the plans of the Nashorn project is off-topic on SO. – Bergi Dec 30 '17 at 22:40
-
1Unfortunately kangax.github.io/compat-table/es6 doesn't include Nashorn. – Bergi Dec 30 '17 at 23:03
-
@Bergi : It does include Nashorn : Looks for JJS – Emmanuel Devaux Aug 1 '18 at 12:36
-
@EmmanuelDevaux Oh, cool that it does now (since February)! – Bergi Aug 1 '18 at 12:47
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
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.
-
The above link seems to be broken, this is the correct link developer.oracle.com/databases/nashorn-javascript-part2.html – Narasimha Jul 17 '19 at 20:55