Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created August 24, 2011 17:05
Show Gist options
  • Select an option

  • Save pasberth/1168551 to your computer and use it in GitHub Desktop.

Select an option

Save pasberth/1168551 to your computer and use it in GitHub Desktop.
send とか getattr とかを js でしてみる
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