我正在尝试模仿mongodb map-reduce。
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中
答案 0 :(得分: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
}