Ok, i’m having a very annoying problem and would appreciate any help.
I’m not sure how to word this, so take a look at EXAMPLE 1, which works, and EXAMPLE 2, which doesn’t work. I don’t understand whey EXAMPLE 2 doesn’t work, and I need it to.
[quote]
/*********
EXAMPLE 1
function test()
{
this.temp
}
function go(obj)
{
alert(obj.temp)
}
UglySquirrel = new test()
UglySquirrel.temp=1
go(UglySquirrel) //alerts “1”
[quote]
/*********
EXAMPLE 2
function test_1()
{
this.temp
}
function test_2()
{
this.testFunction=new Array()
}
go= new test_2()
go.testFunction[0]=new function(obj)
{
alert(obj.temp)
}
UglySquirrel = new test_1()
UglySquirrel.temp=1
go.testFunction[0
It seems that when i declare a function inside of an array, it tries to run the function instead of just storing it for later use. And obviously running the function fails because obj.temp has no value at that point. What can I do to fix this? Any insight into the error of my ways is welcome ?