language versioning

Neil Mix nmix at
Sun Jan 14 12:43:30 PST 2007

Is there any runtime indicator of the language version for backward- 
compatibility checks?  I'm considering this in the context of web  
pages, where you may want to include different scripts based on what  
the browser supports.  For example:

   if (__JAVASCRIPT_VERSION__ >= 2) {
     document.write('<script src="js2-code.js"><\/script>');
   } else {
     document.write('<script src="js2-compiled-as-js1-code.js"><\/ 

If no such version indicator exists, the alternative mechanisms to  
determine capabilities/version would be:
- using a try/catch block to call eval() with version 2 code
- user-agent sniffing
- the (deprecated) "language" attribute of the script tag

Any other options I'm missing?  Of the given options, I think I  
prefer the idea of a runtime indicator.

More information about the Es4-discuss mailing list