DEV Community

Discussion on: Using setTimeout in JavaScript

Collapse
swasdev4511 profile image
Swastik Upadhye

It is beacause setTimeout doesnt guarantee to executre exactly after given time... It means minimum this much time is required...to check this add a settimeout with 500ms.. And then add a for loop that takes 5 sec to eexcute...and check whether the handler in setTimeout executes first or not