Browsers support JavaScript, and Node.js supports it too. I want to know if there any syntax difference between them?
-
Strictly speaking, syntax are technically just rules how the tokens can be and those should be the same for everything that claims to be ECMAScript. But some people (especially those who aren't up to their knees in compiler technology) also include how typical usage of the major APIs looks like (on a higher level) in "syntax". Which one are you talking about?user395760– user3957602011-09-13 17:15:21 +00:00Commented Sep 13, 2011 at 17:15
3 Answers
Node uses Google V8, which implements the ECMAScript standard (link to non official annotated copy).
How it differs from browsers will depend on which browser (and version) you're talking about.
For example, Mozilla browsers implement JavaScript (which is an implementation and superset of ECMAScript).
JavaScript includes:
for each - inloops- destructuring assignment
letexpressions- array comprehensions
...among other enhancements that utilize non ECMAScript standard syntax. These are all part of JavaScript, but not currently part of the ECMAScript standard.
(Of the 4 items listed, the last 3 are proposals for the next ECMAScript version.)
9 Comments
No. The Syntax is exactly the same. There are differences in the apis however. The standard browser dom is not available in node but it has additional apis found at nodejs.org. Any syntax differences are due to quirks in browsers.