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.
Tj crowder
source share