JSFiddle - React, Tailwind, and code Playground
JavaScript
var start = new Date();
// Mimics a long running call for a number of milliseconds
function waitMilliseconds(milliseconds) {
var start = +(new Date());
while(start + milliseconds > +(new Date())) {}
}
// First setInterval call. console.log the time
setInterval(function() {
var current = new Date();
console.log('setInterval executing: ' + (current - start));
}, 1000);
// Some code that takes a while to run
var current = new Date();
console.log('start long running code: ' + (current - start));
waitMilliseconds(1500);
current = new Date();
console.log('end long running code: ' + (current - start));