var while 1000 setTimeout function 1000

1
2
3
4
5
6
var n=0;
while(n<1000) {
setTimeout(function() {
n++;
},1000)
}