Strict mode callbacks and setTimeout

Luke Hoban lukeh at
Wed Jul 6 12:21:04 PDT 2011

I recall there was some previous confirmation that the expected strict mode behaviour of this code was to alert 'undefined':

  var f = function() { "use strict"; alert(this); }

However, what about similar code using setTimeout?


>From HTML5 setTimeout [1], I see the following, which appears to be clear that the thisArg is 'undefined':

"If the first argument to the invoked method is an object that has an internal [[Call]] method, then return a task that checks if the entry for handle in list has been cleared, and if it has not, calls the aforementioned [[Call]] method with as its arguments the third and subsequent arguments to the invoked method (if any), and with an undefined thisArg, and abort these steps. [ECMA262]"

I would then expect ES5 10.4.3 to take care of setting 'this' to undefined.

However, no current browser appears to alert 'undefined' in the second sample above, even those that do report 'undefined' for the first.  

Is the reasoning above correct?  Is 'undefined' the expected result of both examples?



More information about the es5-discuss mailing list