If I have a function which I would like my js code to run it immediately but after the run, wait for 2 seconds. How to achieve this logic?
(Note: It is just the inverse logic compare with setTimeout(), since setTimeout() first wait a certain amount of time then execute the function.)
Just put your code inside an anonymous function passed to setTimeout.
e.g.