Skip to content

Instantly share code, notes, and snippets.

@gumayunov
Created January 4, 2011 08:56
Show Gist options
  • Save gumayunov/764554 to your computer and use it in GitHub Desktop.
Save gumayunov/764554 to your computer and use it in GitHub Desktop.
var A = function(){
console.debug("A constructor");
A.build();
};
(function(){
var p = 0;
this.B = function(){
console.debug('B constructor');
};
this.B.prototype = {
foo: function(){console.debug("p:",p); return p;}
};
var self = this;
this.build = function() {
console.debug('build function');
return new self.B();
}
}).apply(A);
var a = A.build();
var aa = new A();
var b = new A.B();
console.debug([a,aa,b, b.foo() ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment