SOURCE

let arr = [5,4,1,3,2];
	arr.forEach((item,index)=>{
		setTimeout(()=>{
			console.info(item);
			if(index>=arr.length-1) {
				console.info('循环完了');
			}
		},item*100);
	});
	
	(function loop(i){
		setTimeout(()=>{
			console.warn(arr[i]);
			if(++i>=arr.length) {
				console.warn('循环结束');
			} else {
				loop(i);
			}
		},arr[i]*100);
	})(0);
console 命令行工具 X clear

                    
>
console