更新时间:2022-05-17 08:56:04
使用方括号:
some_object["string_containing_method_name"]();
如果你想玩全局变量,那么只要记住它们都是 window
object。
If you want to play with globals, then just remember they are all properties of the window
object.
...但不要使用全局。
您的特定示例:
var $classname = "klasse";
var $class = new window[$classname]();
(显然,在机器生成的代码中只使用$的常规约定也应该适用)
(Obviously, the usual conventions for only using $ in machine generated code should apply too)