var num = 10000for (var i = 0; i++; i < num) { eval("pp" + i + "=" + i);}(function(window, undefined){ var a1 = new Date(); for (var i = 0; i < num; i++) { document.write(window["pp" + i]); } var a2 = new Date(); alert(a2.getTime() - a1.getTime());})(window);(function(undefined){ var a1 = new Date(); for (var i = 0; i < num; i++) { document.write(window["pp" + i]); } var a2 = new Date(); alert(a2.getTime() - a1.getTime());})();
速度提升2/3
来自:http://blog.csdn.net/qq1119753812/article/details/6820697
PS:在一间屋子里找一个杯子,和在茶几上找一个杯子;