1
我的代码首先产生以下两行:线消失
1,2,3,4,5 1,2,3,4
然后它产生这些线,并且在这两个消失:
1,2,3 1,2 1
这究竟是为什么?
var arr=[1,2,3,4,5];
document.write(arr+"</br>");
function popit() {
if(arr.length>0) {
arr.pop();
if(arr.length<=0) {
clearTimeout(p);
document.write("end");
}
var p=setTimeout(popit,1000);
document.write(arr);
document.write("</br>");
}
}
window.onLoad=popit();
入住这里http://stackoverflow.com/questions/802854/why-is-document-write-considered-a-bad-practice – elclanrs