Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What version of Javascript is supported in node.js

I'm getting started with Node.js and I'm having a hard time figuring out what version of JavaScript is supported by node which makes it difficult figuring out what features I can use. Here's what I know.

  • Node uses V8
  • V8 implements ECMAScript as specified in ECMA-262, 3rd edition
  • ECMA-262, 3rd edition is JavaScript 1.5

Given this, I would assume I can use JavaScript 1.5 compatible code in node. However, it turns out I can use the Array.forEach, among other constructs, even though according to MDC it isn't available until Javascript 1.6 -- ECMA-262, 5th edition.

Where am I going wrong? Is there a document somewhere that details the available language features?

like image 274
emtrane Avatar asked Feb 28 '11 07:02

emtrane


People also ask

What version of JavaScript does Nodejs use?

Node uses Google's V8 JavaScript engine for language implementation. New language features in Node depend on them being implemented first in V8. The V8 project pushes forward steadily and the team releases a new version roughly every six weeks.

Does Nodejs 14 support ES6?

Node js doesn't support ES6 import directly. If we try to use import for importing modules directly in node js it will throw out the error.

Does Nodejs support JavaScript?

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser, which was designed to build scalable network applications.

What ECMAScript version does Node support?

The result is that currently Node LTS (16.13. 1), includes V8 9.4, which supports all the ECMAScript 2022 features.


1 Answers

This matrix (V8 follows the WebKit column fairly closely) seems to pretty well answer the question "what features can I use?" but I can't find a canonical answer to "what version of javascript is supported?" As far as I can tell, the best answer is this: ECMA-262 3rd edition is supported, but many features of the 5th edition are also supported.

There's a good explanation of why V8 follows the WebKit and JavaScriptCore functionality on this thread.

like image 64
Benson Avatar answered Sep 19 '22 23:09

Benson