R
risingfish
Hello, I would call myself a fairly competent JavaScript programmer,
but I ran into something expected today. Here's a snippet:
NS.MyClass = function () {
var initialize = function() {
/* do something */
NS.Instances[<uniqueId>] = this;
}
initialize();
}
var obj = new NS.MyClass();
The object that ends up in NS.Instances[<uniqueId>] is DOMWindow, not
the particular instance of that class. I can obviously fix it with
call() but I've found a hole in my knowledge and am trying to
understand. Could someone explain what is happening there?
Thanks!
R
but I ran into something expected today. Here's a snippet:
NS.MyClass = function () {
var initialize = function() {
/* do something */
NS.Instances[<uniqueId>] = this;
}
initialize();
}
var obj = new NS.MyClass();
The object that ends up in NS.Instances[<uniqueId>] is DOMWindow, not
the particular instance of that class. I can obviously fix it with
call() but I've found a hole in my knowledge and am trying to
understand. Could someone explain what is happening there?
Thanks!
R