0

I'm doing all sorts of JS experiments to clarify various language points, many being run in Eclipse using Run As --> Node application (or Node program).

I'm surprised to find that Array.prototype.flat() is not available, although it is in my browser (Firefox 70), and am wondering what version of JS my Eclipse NodeJS installation is running.

My system's CLI version of NodeJS is v10.16.3. This also does not recognise Array.flat(). I haven't been able to find out the version of ECMAScript to which this corresponds (if it does). The version of "NodeEclipse" installed in Eclipse is said to be 1.0.2. I don't know how to read across from there to the NodeJS version...

There's a "pure-JS" answer here about obtaining the JS version, but you have to access the document, which I can't when I'm not running in a browser. Isn't there a simple way to find this out?

I'm confused: does Eclipse run a particular version of Node, and does a particular version of Node correspond to a particular version (ECMAScript version) of JS?

If I could just somehow get the Node version and the ES version when running a script this would help a great deal! Maybe there's some idiot-proof feature test?

PS

To add to my general bafflement: Array.flat() is not listed in the general page for Array.prototype, but it is listed as a method of Array.prototype on another page. Nor do either of these pages say to which ECMAScript version they correspond. Perhaps I should presume it is the latest for FF, since this is Mozilla, (i.e. ES7)?

mike rodent
  • 14,126
  • 11
  • 103
  • 157
  • Could you use Eclipse's built-in browser and use the method described in the link? I would guess that the browser would use the same version as Eclipse itself, but I can't actually say anything for certain. Also, not sure if NodeJS is any better, but from my experience with other JS libraries and frameworks, Eclipse's javascript support is awful. It made my life so much easier when I switched to something better suited for it. – Andrew Robie Nov 05 '19 at 21:51
  • When I use a simple .htm file to run any .js script file (Open with --> Web browser) Eclipse opens a new tab in my default browser, FF 70, which **is** able to recognise `Array.flat()`. Clearly the JS version being run in that configuration is a more up-to-date one... (ES7). – mike rodent Nov 05 '19 at 21:58

0 Answers0