Reputation: 198188
Browsers support JavaScript, and Node.js supports it too. I want to know if there any syntax difference between them?
Upvotes: 6
Views: 8084
Reputation: 322452
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 - in
loopslet
expressions...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.)
Upvotes: 14
Reputation: 4682
No. The syntax is exatcly the same, but you're working it provides with different environment - for example, you don't have DOM and have API for file system access and sockets.
Upvotes: 1
Reputation: 7671
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.
Upvotes: 8