2011-08-03 11 views
0

私はmongodb map-reduceを嘲笑しようとしています。 Functionさんcall methodを使用して、JavaScriptやjQueryの中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 
} 

答えて

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 
}