title: jquery widget apply(this, arguments)
body: <p>Sometimes I see people using this to call function within a widget</p>
  
  <pre><code>this.myFunction.apply(this, arguments);
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>this.myFunction();
  </code></pre>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/3796788/whats-the-apply-jquery-function">What&#39;s the .apply jQuery function?</a></p>
  
  <pre><code>somefunction.apply(thisobj, argsarray)
  </code></pre>
    
    <p><em>The above calls the function somefunction, setting this to thisobj within the function's scope, and passing in the arguments from
    argsarray as the arguments to the function.</em></p>
  </blockquote>
  
  <p>But considering the case below, wouldn't it be the same whether calling the function directly or using .apply()? I've seen a few tutorials favor .apply() method instead, including the jQuery site itself. <a href="http://jqueryui.com/demos/widget/" rel="nofollow noreferrer">http://jqueryui.com/demos/widget/</a></p>
  
  <p>Is this a widget 'standard' or is there something else that i'm missing?</p>
  
  <pre><code>_create: function() {
              var that = this;
              this.myButton = $( "&lt;button&gt;", {
                  text: "My Button"
              })
              .appendTo( this.element )
              .bind("click", function() {
                  // _bind would handle this check
                  if (that.options.disabled) {
                      return;
                  }
                  that.displayMessage.apply(that, arguments);
                  // Why not just call the following?
                  // that.displayMessage();
              });
          },
  displayMessage: function() {
          alert("Hey!");
      }
  </code></pre>