5
Javascript从字符串动态调用对象方法
我可以动态调用以方法名称为字符串的对象方法吗?我会这样想: 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();