![]() Therefore, the above sleep() method will only suspend the execution of the function where you'll call it. ![]() Remember that due to the asynchronous nature of JavaScript, it is not possible to stop the entire program execution. But after the introduction of promises in ES6, we can easily implement such a feature in JavaScript to make a function sleep: const sleep = ( ms ) => timer ( ) // Start time -> T08:42:34.754Z // After 2s -> T08:42:36.763Z // After 4s -> T08:42:38.764Z However, this functionality is not available in JavaScript due to its asynchronous execution model. Similarly, PHP has sleep(2), and Python has time.sleep(2) to make the program stops for 2 seconds. For example, in Java, you can use the Thread.sleep(2 * 1000) to halt the current thread execution for 2 seconds. Similarly, PHP has sleep (2), and Python has time.sleep (2) to make the program stops for 2 seconds. ![]() For example, in Java, you can use the Thread.sleep (2 1000) to halt the current thread execution for 2 seconds. Many programming languages provide a sleep() function that pauses the execution of the code for a certain amount of time. Many programming languages provide a sleep () function that pauses the execution of the code for a certain amount of time. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |