Consider this:
  var Foo = function Foo () {
      var numberVar = 0;
      fooPrototype = {
          getNumberVar: function () {
                return numberVar;
          },
          setNumberVar: function (val) {
                this.numberVar = val;
          }
      }
      return fooPrototype;
  };
  var foo = new Foo();
Alternatively, look at this:
  var Bar = function Bar() {
        var numberVar = 0;
  };
  Bar.prototype = {
      getNumber: function () {
          return this.numberVar;
      },
      setNumber: function (val) {
          this.numberVar = val;
      }
  };
  var bar = new Bar();
They both do the same thing, in that they allow for public / private members. Is there any benefit to doing this one way or the other?
 
     
     
    