Author: failingProgramMember-eight gods
Does JS have sleep functions ?, Yes, we add it ourselves.
How many seconds does function sleep in JS? This problem is often raised by beginners of JavaScript, since the emergence of JavaScript.
That's why this function is not provided in Js?
Currently, all browsers parse Js in the UI thread. Taking Firefox as an example, I re-compiled the JS engine and added the sleep method to the JS alert. This method is called.C LanguageThread sleep function.
Attaches the method to the object, and the method signature is sleep (); No parameter. The default sleep is 1 second. If you call this function in JS, the browser UI interface will be blocked.
In addition, if your JS function has an endless loop, the browser's Js parsing will detect JS execution timeout and remind you whether to terminate the execution of JS on this page.
Finally, a newly compiled JS engine is provided. replace them with the JS engine in Firefox.
Then you can write a piece of Js for fun, such as "testsleep". Sleep (); because I added it to an object, you can call this function on any JS object.
Attachment: firefox_js.rar