Can IE interpret both JScript and JavaScript?

The IE window.setTimeout link indicates that setTimeout has an optional third parameter that defines the language.

Possible languages ​​are JScript, VBScript, and JavaScript.

I already know that IE can parse VBScript, but

How does IE handle JavaScript differently from JScript?

Personally, I thought that the EcmaScript dialect that IE parsers and launches was called by JScript.

[ Edit ]

As people mentioned, it looks like Microsoft calls its ES3 engine “JScript” and its ES5 engine “JavaScript”. The ES5 engine is in IE9.

Can we use their ES3 engine in IE9 by going to "JScript" in setTimeout ?

+7
source share
6 answers

Personally, I thought that the EcmaScript dialect that IE parsers and launches was called by JScript.

It. The "JScript" and "JavaScript" values ​​for the third parameter are simply synonymous. I can’t find a link for it, but you can be sure that in IE there are no two separate interpreters that lie around with JScript isms, and the other is not.

And here is the proof: if you run this in IE9 ( live copy ):

HTML:

 <input type='button' id='btnJScript' value='JScript'> <input type='button' id='btnJavaScript' value='JavaScript'> 

JavaScript:

 window.onload = function() { document.getElementById('btnJScript').onclick = function() { testIt("JScript"); }; document.getElementById('btnJavaScript').onclick = function() { testIt("JavaScript"); }; function testIt(lang) { var s = "var a = [1, 2, ]; display(a.length);"; display("Calling <code>setTimeout</code> with <code>'" + s + "', 0, '" + lang + "'</code>"); setTimeout(s, 0,lang); } }; function display(msg) { var p = document.createElement('p'); p.innerHTML = msg; document.body.appendChild(p); } 

In both cases, you get the output "2" displayed by the string eval'd setTimeout . But in JScript, even the most recent version in IE8, this trailing comma means the array had three entries, not two. Details about this are here. Thus, IE9 uses its last interpreter in both cases, rather than switching to "JScript" in some way if you pass "JScript" as the third parameter.

Refresh . And similarly (I just activated my IE8 box), if you ran it in IE8, you will get "3" in both cases.

+6
source

From this MSDN page, you can see that JScript is the Microsoft name for its implementation of ECMAScript 3, while JavaScript is the name for the implementation of ECMAScript 5 that appears in IE9.

+3
source

I think the best answer I could give someone else has already done.

Well known, Mr. Resig personally: http://ejohn.org/blog/versions-of-javascript/

code snippet

  • IE 6-7 supports JScript 5 (equivalent to ECMAScript 3, JavaScript 1.5)
  • IE 8 supports JScript 6 (equivalent to ECMAScript 3, JavaScript 1.5 - bug fixes in JScript 5)
  • Firefox 1.0 supports JavaScript 1.5 (ECMAScript 3 equivalent)
  • Firefox 1.5 supports JavaScript 1.6 (1.5 + Array Extras + E4X + miscellaneous).
  • Firefox 2.0 supports JavaScript 1.7 (1.6 + Generator + Iterators + let + misc.)
  • Firefox 3.0 supports JavaScript 1.8 (1.7 + Generator Expressions + Expression Closures + misc.)
  • The next version of Firefox will support JavaScript 1.9 (1.8+ for definition)
  • Opera supports a language equivalent to ECMAScript 3 + Getters and Setters + misc.
  • Safari supports a language equivalent to ECMAScript 3 + Getters and Setters + misc.

I think the IE9 JScript ( Chakra ) engine comes as close to Javascript as possible. However, it does support many ES5 features. See " IE9 Javascript engine ". Therefore, we could probably expand the above list with

  • IE9 supports JScript 9 (equivalent to ECMAScript 5, JavaScript 1.8.5)
+2
source

You can safely think that JScript is the same as JavaScript, and you will not encounter any problems.

http://en.wikipedia.org/wiki/JScript#Comparison_to_JavaScript

+1
source

JScript and Javascript are the same in IE. JScript has been renamed JavaScript in IE9 due to a more standard (or better, more compatible) implementation.

+1
source

The manual page that you are linking to indicates that sLanguage is a parameter that can accept VBScript , JScript or Javascript values.

It's not that JScript is different from Javascript, it's just that both are valid names for the same language, they must support both names.

JScript is Microsoft's name for its reverse Javascript cloning. The languages ​​are now combined by the ECMA standardization work, which results in EcmaScript, although it is still commonly called Javascript.

But Microsoft must support both names because they want to maintain compatibility with old code written for ancient versions of IE, which still uses the old JScript name.

+1
source

All Articles