When I run the following code, this
returns [object Object]
and then returns [object Window]
. I understand that this
refers to the owner of the function. I understand that window
is the owner of the function in the latter case. But who is the owner of the function in the former case? In that case, who is [object Object]
?
function Customer(name) {
this.name = name;
alert(this);
}
var x = new Customer('John');
Customer('Smith');