How to wait 1 second in JavaScript (using setTimeout, Promise, and Delay)

Call it a wait, sleep, or delay in executing code in JavaScript. It can be done…