Created
January 30, 2012 00:11
-
-
Save specialunderwear/1701513 to your computer and use it in GitHub Desktop.
constructor defines methods
This file contains hidden or 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 Counter = function(from) { | |
> this.from = from; | |
> this.next = function() { | |
> this.from += 1; | |
> return this.from; | |
> }; | |
> } | |
> var count_from_7 = new Counter(7); | |
> var count_from_3 = new Counter(3); | |
> count_from_7.next(); | |
8 | |
> count_from_3.next(); | |
4 | |
> count_from_7.next(); | |
9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment