JSFiddle - React, Tailwind, and code Playground

by karthick6891

JavaScript

setTimeout(function timeout(){
	console.log('hi', new Date().getTime());
}, 1000);

setTimeout(function timeout(){
	console.log('hi 2', new Date().getTime());
}, 1000);

setTimeout(function timeout(){
	console.log('hi 3', new Date().getTime());
}, 1000);

setTimeout(function timeout(){
	console.log('hi 4', new Date().getTime());
}, 1000);


[1,2,3,4].forEach(function (i){
    console.log(i,new Date().getTime());
});

function asyncArr(array,cb){
    array.forEach(function(){
       setTimeout(cb, 0); 
    });
}

asyncArr([1,2,3,4], function(i){
    console.log(i);
});