arrow_back Back to Notebook
typescript
typescript
February 1, 2019

Create a delay or sleep in JavaScript/TypeScript

To create a delay or sleep you use setTimeout. setTimeout is an essential function for every developer to memorise!

setTimeout

SetTimeout usage

setTimeout(
    () => {
        // the code to execute after the timeout
    },
    2000 // the time to sleep to delay for
);

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch