Indirect eval function called are now globally scoped

Calling eval methods indirectly (that is, other than by the explicit use of its name) inside a function produces different results in Windows Internet Explorer 9 and later versions that it does in earlier versions (and document modes).

In earlier versions of Windows Internet Explorer (and corresponding document modes), the string passed to the indirect eval is evaluated in the local function scope. Starting with IE9 Standards mode, it is evaluated in the global scope as per the ECMAScript Language Specification, 5th edition.

The eval function behaves as expected in IE5 (Quirks) mode, IE7 Standards mode, and IE8 Standards mode but returns "undefined" in IE9 mode.

Call the eval method directly.

In the following example, the eval function has been called indirectly by assigning it to a variable and calling the variable as if it were eval.

function test() {
   var dateFn = "Date(1971,3,8)";
   var myDate;
   var indirectEval = eval;
   indirectEval("myDate = new " + dateFn + ";");
   document.write(myDate);
}
test();

This sample will return "Thu Apr 8 00:00:00 PDT 1971" in earlier versions of Internet Explorer (and related document modes). Starting with IE9 mode, this prints "undefined".