1. 程式人生 > >每隔0.5s迴圈列印5,6,7,8,9,10,9,8,7,6,5,6,7,8........

每隔0.5s迴圈列印5,6,7,8,9,10,9,8,7,6,5,6,7,8........

		function conLog(){
				var i=4,j=0;
				var timer=setInterval(function(){
					j++;
					if(j<=6){
						i++;
					}else{
						i--;
						if(j==10){
							clearInterval(timer);
							conLog();
						}
					}
					console.log(i)
				},500)
			}
			conLog();