title: Javascript chain rule, return specific value instead of [Object object] [x]
body: <p>The question is at the title, but first please look at this code:</p>
  
  <pre><code>function number(a) {
      return {
          add: function(b) {
              result = a + b;
              return this;
          }, substract(b) {
              result = a - b;
              return this;
          }
  }
  </code></pre>
  
  <p>These code above are simple example of chain rule. I retun an object so I can do it continuously:</p>
  
  <pre><code>number(2).add(5).add(3 * 12).substract(Math.random());
  </code></pre>
  
  <p>My problem is, I have to retun an object to keep the function chainable. I'd like to immitate the chain rule, but to return specific value. For instance <code>number(2).add(3)</code> would return 5.</p>
  
  <p>Any suggestion is highly appreciated.</p>
  
  <p>Thanks everyone in advanced.
  [x]</p>