code: function makeSmartClass() {
  		function SmartClass(args) {
  			// Was the keyword "new" used?
  			if (this instanceof SmartClass) {
  				if (!initializing && typeof this.init == 'function')
  					this.init.apply(this, args && args.callee ? args : arguments);
  			} else {
  				return new SmartClass(arguments);
  			}
  		};
  
  		return SmartClass;
  	}
docs: @example
  
  var A = makeSmartClass();
  A.prototype.init = function(x) { this.x = x; };
  
  // Both ways are valid:
  var instance1 = new A(2);
  var instance2 = A(2);