there is a built-in function (sleep()) in php that delays execution of the current script for a specified number of seconds. it can be put anywhere and it will do the job.
here are its explanation:
http://www.w3schools.com/php/func_misc_sleep.asp
http://php.net/manual/en/function.sleep.php
my question: does a such function exist in javascript?
JavaScript generally tries to be non-blocking. There is no
sleep()orwait()or anything like that. Functions likesetInterval()orsetTimeout()can defer execution of a function to a later time, which is useful. However, the current script does not stop executing after those functions are called. It continues running until a separate built-in mechanism, whether it’s a timer, a signal, or otherwise, executes the function that was specified insetTimeout().