My debugging work in IE ended today by finding that constructor.name
is undefined
.
I created the following simple code that reproduces the issu
Perhaps this example clears up some confusion.
var number = 10; //A global variable. Part of the global window object.
//window.number = 10; //Does exactly the same as the line above.
var customer = {
number: 20,
speak: function () {
if (this === window) {
alert('I am being called by go() ' + this.number); //this.number points to the global variable number
} else {
alert('I am being called by customer.speak ' + this.number); //this.number points to the customer member number
}
}
}
var go = customer.speak; //Go now points directly to the function called "speak" as if it is not a part of the customer object. The this parameter of speak will be the global window object;
go();
customer.speak(); //Now the speak function is called a part of the customer object. The this parameter of speak will be the customer object