jQuery插件调用内部函数

Pas*_*yer 1 javascript jquery anonymous-function jquery-plugins

我想在内部调用removeSomething()(参见第9行):

JS代码是:

    (function($){
      $.fn.extend({
        Engine: function(options) {
          var defaults = {
           ...
          };
          var options = $.extend(defaults, options);

          removeSomething();

          //-----------------------------------------------------------------------
          //Public Functions ------------------------------------------------------
          //-----------------------------------------------------------------------

          this.removeSomething = function() {
            ...
          }; 
        }
      });
   })(jQuery);
Run Code Online (Sandbox Code Playgroud)

但是,如果我调用removeSomething控制台输出removeSomething不是一个函数,我该怎么调用这个函数?该功能应该在内部和外部可用.

感谢帮助!

Nic*_*ver 5

在使用var或者使用其他= function() {...语法声明它时,需要使用之前定义函数,并调用它但是它已被定义,在这种情况下:

this.removeSomething = function() {
  ...
}; 
//*then*
this.removeSomething();
Run Code Online (Sandbox Code Playgroud)