Created
September 5, 2013 09:50
-
-
Save nakosung/6448113 to your computer and use it in GitHub Desktop.
scope inheritance
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
gen_scope = (parentScope) -> | |
Scope = -> | |
Scope.prototype = parentScope | |
new Scope() | |
a = gen_scope() | |
a.x = 1 | |
b = gen_scope a | |
b.y = 2 | |
c = gen_scope b | |
c.z = 3 | |
console.log c.x, c.y, c.z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment