Created
August 24, 2011 17:05
-
-
Save pasberth/1168551 to your computer and use it in GitHub Desktop.
send とか getattr とかを js でしてみる
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
| function getattr(self, attrname) { | |
| return (function() { | |
| return eval("this." + attrname); | |
| }).apply(self, arguments); | |
| } | |
| function send(self, funcname) { | |
| return (function() { | |
| return eval("this." + funcname + "(arguments);"); | |
| }).apply(self, arguments); | |
| } | |
| function test() { | |
| alert(getattr([1, 2, 3], "length")); | |
| alert(send([1, 2, 3], "push", 4)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment