title: How to make chainable function in JavaScript?
body: <p>Lets imagine function like this:</p>
  
  <pre><code>function foo(x) {
      x += '+';
      return x;
  }
  </code></pre>
  
  <p>Usage of it would be like:</p>
  
  <pre><code>var x, y;
  x = 'Notepad';
  y = foo(x);
  console.log(y); // Prints 'Notepad+'.
  </code></pre>
  
  <p>I'm looking for a way to create function that's chainable with other functions.</p>
  
  <p>Imagine usage:</p>
  
  <pre><code>var x, y;
  x = 'Notepad';
  y = x.foo().foo().toUpperCase(); // Prints 'NOTEPAD++'.
  console.log(y);
  </code></pre>
  
  <p>How would I do this?</p>