我可以动态调用方法名称为字符串的对象方法吗?我会想象它是这样的:
var FooClass = function() {
this.smile = function() {};
}
var method = "smile";
var foo = new FooClass();
// I want to run smile on the foo instance.
foo.{mysterious code}(); // being executed as foo.smile();
Run Code Online (Sandbox Code Playgroud)