Created
April 29, 2009 13:01
-
-
Save matschaffer/103755 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
MyClass = function() { | |
this.foo = "foo" | |
}; | |
MyClass.prototype = { | |
set foo(v) { | |
print("sorry, I don't wanna set foo with " + v); | |
}, | |
get foo() { | |
return "not really foo"; | |
} | |
} | |
obj = new MyClass(); | |
print(obj.foo); | |
obj.foo = "bar"; | |
/* Output is | |
* sorry, I don't wanna set foo with foo | |
* not really foo | |
* sorry, I don't wanna set foo with bar */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment