Hi All,
Please forgive me if this has already been discussed and resolved for others (I have been unable to find a solution to this so far). My problem is pretty basic, and I would think that every OOP developer would cross this point at some time when using classes in JS, I just haven't found the solution yet.

Well, here's the riddle: I want to call another member function from a member function in a class without loosing the "this"-reference to the class object. In the example below, the 2nd output of this references the window object, and not the instantiated object for some reason (while the first output does reference the object).
PHP Code:
function test_class()
{
    
this.run_me run_me;
    
    function 
run_me()
    {
        
alert("1: " this);
        
run_second();
    }
    
    function 
run_second()
    {
        
alert("2: " this);
    }
}

var 
test = new test_class();
test.run_me(); 
Any ideas how I can retain the reference to the object?

Thanks!

PS: Right now I have a work-around hack by passing the reference in the function call. However, this shouldn't really be necessary, right?
PHP Code:
function test_class()
{
    
this.run_me run_me;
    
    function 
run_me()
    {
        
alert("1: " this);
        
run_second(this);
    }
    
    function 
run_second(o_self)
    {
        
alert("2: " o_self);
    }
}

var 
test = new test_class();
test.run_me();