我尝试过的(在chrome中有效)
var class_str = "class Test {};";
var a = eval(class_str);
console.log(new a());
Run Code Online (Sandbox Code Playgroud)
在Firefox 46中引发以下错误:
TypeError: a is not a constructor
Run Code Online (Sandbox Code Playgroud)
a未定义并使用new A()返回ReferenceError: A is not defined.
Firefox有什么不同?