title: Why use extend in JQuery/JavaScript?
body: <p>In the following JQuery UI widget the author has used extend to include two more functions in <code>$.ui.autocomplete</code>, why? Is this a JQuery specific pattern or is it something I could be considering in plain JS?</p>
  
  <pre><code>$.extend( $.ui.autocomplete, {
  escapeRegex: function( value ) {
      return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&amp;");
  },
  filter: function(array, term) {
      var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
      return $.grep( array, function(value) {
          return matcher.test( value.label || value.value || value );
      });
  }
  });
  </code></pre>
  
  <p><a href="https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.autocomplete.js#L385" rel="nofollow">https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.autocomplete.js#L385</a></p>