Hi,
-- I've got a JS function used as a constructor. The HTML file includes code to 'new' the constructor to create the object.
My understanding is that variables defined within the constructor should have the context of the constructor and not of 'window'. But in my case what I'm seeing is that within a declared function in the constructor, the context is 'window':
function MyCtor()
{
var a;
var b;
var myFunc = function() {
debugger; //#2
// code for function
}
// more code
debugger; //#1
myFunct();
debugger; //#3
} //end MyCtor
When execution breaks at debugger #1, 'this' refers to 'MyCtor'. However, at debugger #2 this refers to 'window'. And at debugger #3 it is 'MyCtor'.
What happened to the MyCtor context within myFunc? Clearly I'm missing something basic here.
Thanks.
Les
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.