The outcome of the code you run can vary depending on the hosting environment. For example, if you execute the following:
alert(toString === window.toString);
alert(toString === Object.prototype.toString);
...you may receive different results on different browsers. In Chrome, you might see true
and false
, while in Firefox it could be false
and false
. Internet Explorer may show true
and false
, although there is a caveat.
Browser's handling of the window object can be complex, as it is a host object that may exhibit erratic behavior. For instance, calling toString.call("foobaz")
may not work on IE, because the toString
function of window
is not a standard JavaScript function and lacks the call
or apply
methods. (This doesn't mean it's the correct behavior, of course...)