2

How to check the ECMAScript standard version that the currently installed JS on the system is using, is there any special command to know or we need to check the JS version and then Google it to know on which ES standard version it is based up on.

FZs
  • 16,581
  • 13
  • 41
  • 50
Ritik Banger
  • 2,107
  • 5
  • 25
  • There's no way, JS engines don't even include a specific version, many of the proposed features of the future versions are implemented even years before they're standardized. – Teemu Jan 04 '22 at 06:34
  • Does this answer your question? [How do I know which version of Javascript I'm using?](https://stackoverflow.com/questions/4271566/how-do-i-know-which-version-of-javascript-im-using) – samar taj Shaikh Jan 04 '22 at 06:35
  • What env are you referring to? If you are referring to NodeJS, yes, you can check the version and check if it supports latest features. – Rajesh Jan 04 '22 at 06:35
  • @Rajesh Isn't that a V8 version? – Teemu Jan 04 '22 at 06:36
  • @Teemu V8 is the name of the engine but will that engine support latest features? A lot of people do not use latest Node. Like I'm still on Node 12. Hence I asked for the env OP is using – Rajesh Jan 04 '22 at 06:38

2 Answers2

3

Environments do not run "a particular version of the standard." Rather, environments implement features from different years of the specification piecemeal. For example, it may be that in June 2022, a particular browser has implemented, say, 7 of 9 specification additions or tweaks from the prior year - and a different browser will implement those things on a different schedule.

Even if something is in the standard, there's no absolute guarantee that environments will support it, unfortunately. Usually they will, and often in a reasonably timely manner, but not always. For example, proper tail calls, from ES6, still have not been implemented in V8 or SpiderMonkey.

So, to figure out what is supported in a given environment, you'll have to test all the properties/features you're looking for individually. (eg window.hasOwnProperty('Promise'))

Often, rather than script-writers trying to detect what a browser currently supports, and working around that, script-writers will simply use a polyfill service (example) that adds all necessary missing features - that way you can get on with the main logic of your application and simply not worry about it.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
0

Vanilla JS does not have any version as of Jquery,Angular, Reactjs, etc which are build using vanilla JS. It depends whether the current browser update supports upto which version of ECMA Script. You can use any version syntax as long as you can compile your code to ES5 syntax if your browser does not understand higher version of JS.

Adarsh Niket
  • 1
  • 1
  • 2
  • No versions? Why they keep up a versioned [standard](https://tc39.es/ecma262/multipage/) then? – Teemu Jan 04 '22 at 06:42