Macrotasks and Microtasks
About timer
Note:
About Promises
setTimeout(() => { console.log("timer"); setTimeout(() => { console.log("timeout timeout"); }, 0); new Promise(resolve => { console.log("settimeout Promise"); resolve(); }).then(() => { console.log("settimeout then"); }); }, 0); new Promise(resolve => { console.log("Promise"); resolve(); }).then(() => { console.log("then"); }); console.log("ssss"); Execution order: Promise=>ssss=>then=>timer=>settimeout Promise=>settimeout then=>timeout timeout DOM rendering tasks Browser rendering: CSS+DOM execution encounters JS and JS is executed first Task shared memoryTasks will not be executed simultaneously, but will be scheduled one by one. They share memory. Promise microtasks handle complex businessUsing promises can turn tasks into asynchronous tasks so that they do not affect the execution of synchronous tasks. This is the end of this article about JavaScript macro and micro tasks. For more relevant JavaScript macro and micro tasks, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Summary of basic usage of $ symbol in Linux
>>: Installation and configuration of mysql 8.0.15 under Centos7
This article shares the shell script of mysql5.6....
I encountered a case at work that I had never wri...
Table of contents 1. Comparison of data before an...
Table of contents 1. Clever use of indexes and va...
1. MySql Architecture Before introducing the stor...
1. Prepare a new disk and format it with the same...
Preface I encountered a Mysql deadlock problem so...
GitHub address: https://github.com/dmhsq/dmhsq-my...
1. Add the isolation marker: ip netns add fd 2. P...
Syn attack is the most common and most easily exp...
Today, I encountered a small problem that after s...
Table of contents What is an index The difference...
By default, the MyISAM table will generate three ...
I have been using CSS for a long time, but I have...
This article shares the specific process of js ob...