function(window, undefined)的意义

时间:2022-03-09 05:15:30
var num = 10000
for (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:在一间屋子里找一个杯子,和在茶几上找一个杯子;