title: Best Practices for "Abstract" functions in JavaScript?
body: <p>I just wrote some JavaScript code that follows along with what I believe to be good practice for creating an object with closure and some functions:</p>
  
  <pre><code>var myStuff = (function() {
   var number = 0;
   var fn = {};
   fn.increment = function() { number++; };
   fn.decrement = function() { number--; };
   fn.getNumber = function() { return number; };
   return fn;
  })();
  
  myStuff.increment();
  myStuff.increment();
  alert(myStuff.getNumber()); // alerts '2'
  </code></pre>
  
  <p>I have no problem writing code like the previous snippet.  I would like to write some code with functionality similar to a OOP "abstract" class.  Here is the result of my effort:</p>
  
  <pre><code>var myStuff = (function () {
  var number = 0;
  var fn = {};
  fn.increment = function () { number++; };
  fn.decrement = function () { number--; };
  fn.doSomethingCrazy = function () { throw new Error('not implemented'); }; // I want to specify later what this does.
  fn.doSomethingCrazyTwice = function () { fn.doSomethingCrazy(); fn.doSomethingCrazy(); };
  fn.getNumber = function () { return number; };
  return fn;
  })();
  
  myStuff.doSomethingCrazy = function () { this.increment(); this.increment(); };
  myStuff.doSomethingCrazyTwice();
  alert(myStuff.getNumber()); // alerts '4'
  </code></pre>
  
  <p>The above code snippet works, but it doesn't seem graceful.  Perhaps I'm trying to force JavaScript (a functional language) to do something it isn't designed to do (object inheritance)</p>
  
  <p>What is a good way to define an object in JavaScript so that a function of that object can be defined later?</p>