How many seconds does function sleep in js? Javascript beginners often ask this question. Since the emergence of Javascript, this function is so necessary, but why does js not provide such a function?
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 calls the C language thread 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.
Instructions for use:
It is mainly because Website Visitors need to install your customized browser.
You just need to release the Firefox client.
You must specify your own browser, just as you must install the flash plug-in.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.