Created
October 14, 2011 04:55
-
-
Save goatslacker/1286282 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
// write about this, closures and prorotypes. | |
// can use this | |
// but new's need to be inside function | |
var baz = 0; | |
function Bar() { | |
this.ct = (baz += 1); | |
}; | |
var Foo = function () { | |
this.a = 1; | |
}; | |
Foo.prototype.b = (function () { | |
var c = 2; | |
var f = new Bar(); | |
return function () { | |
c = 4; | |
return f.ct; | |
}; | |
}()); | |
var d = new Foo(); | |
console.log(d.b()); | |
var e = new Foo(); | |
console.log(e.b()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment