Consider code like this:
externa开发者_运维知识库l_function = function() {
    $(this).something2();
}
$('.someclass').live('click', function() {
    $(this).something1();
    external_function(); // wrong way
});
I can add a new method:
external_function = function() {
    $(this).something2();
}
$('.someclass').live('click', function() {
    $(this).something1();
    this.external_function = external_function;
    this.external_function(); // this will work
});
but it seems having overhead to me. Is there a perfect and safe way run external_function with custom context?
You should read about apply and call: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/call
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论