2011-08-03 97 views
0

我試圖嘲弄mongodb map-reduce。javascript對象問題

function some_function(){ 
    .... 
    call_some (some_object); 
    .... 
} 

function call_some (some_object){ 
    // In here, 
    // How could I use this keyword instead of some_object? 
    // some_object.something => this.something 
} 
在JavaScript或jQuery的使用 Functioncall method

回答

1

呼叫call_some

function some_function() { 
    // ... 
    call_some.call(some_object); 
    // ... 
} 

或者,如果你不想把它稱之爲一種特殊的方式做,試試這個:

function call_some(some_object) { 
    if(this !== some_object) { 
     return call_some.apply(some_object, arguments); 
    } 
    // do something interesting here 
    // this === some_object 
}