As for interacting with the DOM, different browsers will offer methods -and results- that are different between them to some or other extent.

But how about JavaScript itself? Do all browsers (or platforms e.g. Adobe Reader) implement the same syntax and behavior?

Aspects that particularly worry me are function/object handling and arithmetical operations.


All browsers that are used today support a common javascript

Javascript is defined by the ECMA-262 standard, either version 3, or version 5. Both versions have the same syntax -- the new things in version 5 are all backwards compatible.

All browsers support the version 3 syntax and objects. Internet Explorer has some brokenness, but supports all the basic syntax and semantics. Firefox has some extensions to the language, but those are disabled on web pages, and are only available for extensions.

The last piece of missing syntax that was seen in a browser was in IE 4.0, which did not have try/catch/finally. That arrived in IE 5.0.

The biggest syntax danger you can still run into today is that IE improperly processes trailing commas in array and object literals. Make sure you don't have any of those, and you can write cross-browser javascript just fine.

  • I don't know about non-browser environments. Except Flash, where actionscript is based on an abandoned version that never became a standard (ES4). – Sean McMillan Sep 30 '11 at 21:07
  • Yeah MainMa's answer somehow suggests this too, printed myself a copy of the 262 standard and all. All the DOM stuff is missing though, obviously. It's great to know that the version 5 retrofits. Thank you. – vemv Oct 2 '11 at 12:32

Different browsers support different versions of JavaScript, and different versions of JavaScript have changes in their syntax. So no, the syntax is not the same, except if you stick with the version old enough to be supported in most browsers.

For example, you can see some cool syntax which, for some, is available in JavaScript 1.8, released in June 2008 and incompatible with FF2 and, as usual, all releases of IE except 9.


The current JavaScript version is 1.8.5. JavaScript has evolved over many stages. So different browsers not only differ in their DOM models, but also in syntax. An overview for browsers is given in Wikipedia. So you should be careful when using advanced features.


But how about JavaScript itself? Do all browsers (or platforms e.g. Adobe Reader) implement the same syntax and behavior?

No. Every browsers support a different version of JavaScript. Not only that, event different versions of the same browsers have different JavaScript capabilities.

This is way there are now numerous ways of ensuring cross-browsers compatibilities for the same JavaScript task, usually requiring feature-detection and then acting based on it.

A good practice to ensure compatibility is to always check for feature detection rather than version detection for browsers.


There are a few gotchas to do with basic Javascript syntax that Internet Explorer will choke on (it might be better in IE9, but IE 6/7/8 had horrible problems).

Things like a trailing comma after the last element in an array (think something like [a, b, c,], every browser will handle it fine except IE.

There are quite a few more along that vein as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.