Timeouts

When you send an email using Gmail, you get a notification saying your email that has been sent and giving you the option to “undo” the sending. After a few moments, the undo option goes away, and the notification just says that your message has been sent. See Figure 7.4.

Image

Figure 7.4 For a few moments, you have the power to unsend your email, but then that power goes away.

The truth is, after an email has been sent, it is not possible to undo. Gmail doesn’t actually send your email until the undo option goes away, and if you click Undo, the email is never sent. JavaScript has a feature called setTimeout that enables you to execute some ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.