title: Javascript - How to add OR extend a function to an existing function
body: <p>I'm working in JS with <a href="https://p5js.org/" rel="nofollow noreferrer">P5.JS</a> and a library to generate a Gui called <a href="https://github.com/bitcraftlab/p5.gui" rel="nofollow noreferrer">p5.gui</a>. This library is a sort of a wrapper for another library called <a href="https://github.com/bit101/quicksettings" rel="nofollow noreferrer">QuickSettings</a>.</p>
  <p>Alright, so this p5.js library is sort of alright, but it lacks functionality. I want to add some functions to it since they are supported by quicksettings, but not by p5.gui.</p>
  <p>For example, I want to be able to add a save or reset Button to the gui menu.
  I've hard coded it into the p5.gui library and it words great. This is the code:</p>
  <pre><code>  this.addButton = function(name, callback) {
      qs.addButton( name, callback );
    };
  </code></pre>
  <p>But what if some time passes and I forget I hardcoded it into the library and the library gets updated. I'll lose my code...</p>
  <p><a href="https://github.com/bitcraftlab/p5.gui/blob/master/libraries/p5.gui.js" rel="nofollow noreferrer">This is the complete (original) code of p5.gui.</a></p>
  <p>And this is, in reference and stripped where I put my code:</p>
  <pre><code>  (function() {
  
      function QSGui(label, parent, sketch) {
        
        // my code
        this.addButton = function(name, callback) {
          qs.addButton( name, callback );
        };
        // end my code
  
      }
  
    })();
  </code></pre>
  <h2>The question</h2>
  <p>So, my question would be if there is a way to add code to it or extend to it from my own file/script.
  I'm not familiar enough with JS to do this. I saw I can't call <code>QSGui()</code> directly from another file as well.</p>