有一种用法比较特别:
var foo3 = new Function('var temp = 100; this.temp = 200; return temp + this.temp;');
alert(typeof(foo3));
alert(foo3()); 输出:
function
300
(new Function('...'))()将会执行引号中的内容,与eval效果差不多
版权声明:本文为juroney1原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。