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
For websites with an architecture like LNMP, they...
Step 1: Install Stow In this example, we are usin...
Problem Description I recently encountered a prob...
mycli MyCLI is a command line interface for MySQL...
1. MySQL installed via rpm package service mysqld...
Preface If you frequently access many different r...
Table of contents Install mysql Configuring envir...
This article describes the Mysql self-join query....
Today we are going to implement a Thunder Fighter...
1. A static page means that there are only HTML ta...
Before starting the main text of this article, yo...
The arrangement layout of aligning the two ends o...
If you want the entire interface to have a backgr...
Note 1: The entire background in the above pictur...
Flex layout is a commonly used layout method nowa...