Created
January 4, 2011 08:56
-
-
Save gumayunov/764554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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