JSFiddle - React, Tailwind, and code Playground
JavaScript
// Alert blocks thread - in particular setTimeout is paused.
function now(){ return (new Date()).getTime() }
var elapsed_before_interruption
// This will interrupt the function below
setTimeout(function(){
elapsed_before_interruption = now()-start
alert('Paused')
start = now()
}, 2000)
var start = now()
setTimeout(function(){
var elapsed_since_interruption = now() - start
var elapsed = elapsed_since_interruption + elapsed_before_interruption
var tenth_second = Math.round(10 * elapsed / 1000)/ 10
alert( 'Elapsed time: ' + tenth_second + 's' )
alert()
}, 4000)