What is the difference in JavaScript syntax between node.js and browsers?

Browsers support JavaScript, and Node.js also supports it. I want to know if there is a difference in syntax between them?

+4
source share
3 answers

Node uses Google V8 , which implements the ECMAScript standard (link to an unofficial annotated copy).

How it differs from browsers depends on which browser (and version) you are talking about.


For example, Mozilla browsers implement JavaScript (this is an implementation and a superset of ECMAScript).

In JavaScript there are:

  • for each - in loops
  • destruction purpose
  • let expressions
  • understanding array

... among other improvements that use the standard ECMAScript syntax. All of them are part of JavaScript, but are not currently part of the ECMAScript standard.

(Of the 4 items listed, the last 3 are suggestions for the next version of ECMAScript.)

+14
source

No. The syntax is exactly the same. However, the differences are in apis. The standard dom browser is not available in node, but it has an additional apis found in nodejs.org . Any syntax differences are related to quirks in browsers.

+5
source

No. The exatcly syntax is the same, but you are working, it provides a different environment - for example, you do not have a DOM and there is an API for accessing the file system and sockets.

+1
source

All Articles