4

I found that Node use Chrome's V8 JavaScript engine. There's some information about ES6 support here, and here. There's even a switch for V8 options when using Node:

node --v8-options

But none of the options seems to allow the selection of the ECMAScript version.

Moreover here I found the information that few years ago Node supported ES3, but later, with the evolution of V8 it switched to ES5.

Is it possible to force Node to use versions of ECMAScript older than 5-th? Does currently used V8 engine support ES version selection at all?

Community
  • 1
  • 1
Arkadiusz Kałkus
  • 17,101
  • 19
  • 69
  • 108

2 Answers2

3

All versions of EcmaScript are backwards-compatible with the previous versions.

ES3 features work in ES5, and ES5 features work in ES2015, so there should be no need to specifically run code in an ES3 enviroment, as ES3 code should work fine in ES5 and ES2015.

In general, there haven't been any breaking changes added to new versions of EcmaScript, even in ES5 when they decided to try and clean up the language a bit, they decided to add use strict, as to not break anything in old code that ran in ES3.

Javascript engines do not generally have an option to run different versions of EcmaScript, as it shouldn't be needed, the latest version should be compatible with all previous versions of the standard.

adeneo
  • 312,895
  • 29
  • 395
  • 388
  • That's true, however I wanted to run ES3 to experiment with older versions. In particular I wanted to show on a live demo that TypeScript can run on ES3 (targets are 'es3', 'es5', 'es6', 'es2015') so even on very old browsers we can get modern features. I also wanted to see if TS compiler will properly modify operations like Object.create() introduced in ES5 to run in ES3. – Arkadiusz Kałkus Nov 12 '16 at 19:31
  • 1
    Then I think your only option is to try and find an engine that is old enough that it only supports ES3, and that's not going to be Node, you'd have to go back years before Node was released, back to Netscape Navigator 1.0 and 1995 or around that time. – adeneo Nov 12 '16 at 19:40
  • @adeneo, what about `Duplicate property names` in JS? In ES5 in strict mode they are considered as Syntax Error. But in ES2015, they removed error due to possible collision of `Computed property names`. So what if I want to enable that syntax error? – Turkhan Badalov Jul 10 '17 at 12:13
3

JS engines are no longer versioned against spec, because implementers didn't implement all features of a spec, and the feature sets which all vendors implemented certainly weren't in line with one another. It was a short-lived dream.

In order to demo on ES3, you'll need to run IE6 - 8. ...which has its own problems, because IE had quirks which make that hard, but plausibly doable.

Norguard
  • 26,167
  • 5
  • 41
  • 49