当前位置:网站首页>专题 | 同步 异步
专题 | 同步 异步
2022-07-03 07:18:00 【快乐的高兴的学习代码中】
1.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log(1);
console.log(2);
console.log(3);
</script>
</body>
</html>
2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log(1);
setTimeout(function(){
console.log(2);
},1000)
console.log(3);
</script>
</body>
</html>
3.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log(1);
setTimeout(function(){
console.log(4);
},0)
console.log(3);
</script>
</body>
</html>
4.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log(1);
setTimeout(function(){
console.log(2);
},3000)
setTimeout(function(){
console.log(3);
},1000)
</script>
</body>
</html>
5.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log('1');
setTimeout(function () {
console.log('2');
new Promise(function(resolve, reject) {
console.log('promise-start2');
resolve();
}).then(function() {
console.log('promise-end2');
});
},0);
new Promise(function(resolve, reject) {
console.log('promise-start');
resolve();
}).then(function() {
console.log('promise-end');
});
setTimeout(function () {
console.log('3');
},0);
console.log('4');
</script>
</body>
</html>
还是不懂promise的目的
6.这个经典,随便换着位置理解
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
console.log('1');
new Promise(function(resolve, reject) {
console.log('promise-start2');
// setTimeout(function () {
// console.log('6');
// },0);
resolve();
}).then(function() {
setTimeout(function () {
console.log('3');
},0);
console.log('promise-end2');
});
console.log('4');
</script>
</body>
</html>
边栏推荐
- GStreamer ffmpeg avdec decoded data flow analysis
- Sorting, dichotomy
- I. D3.js hello world
- 10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
- The education of a value investor
- The underlying mechanism of advertising on websites
- LeetCode
- 深度学习参数初始化(一)Xavier初始化 含代码
- centos php7.2.24升级到php7.3
- C WinForm framework
猜你喜欢
Final, override, polymorphism, abstraction, interface
JMeter JSON extractor extracts two parameters at the same time
7.2 brush two questions
Pits encountered in the use of El checkbox group
My 2020 summary "don't love the past, indulge in moving forward"
Mise en place d'un environnement de développement de fonctions personnalisées
[set theory] partition (partition | partition example | partition and equivalence relationship)
SecureCRT取消Session记录的密码
TCP cumulative acknowledgement and window value update
Store WordPress media content on 4everland to complete decentralized storage
随机推荐
Common problems in io streams
MySQL mistakenly deleted the root account and failed to log in
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
深度学习参数初始化(一)Xavier初始化 含代码
[attribute comparison] defer and async
Advanced API (serialization & deserialization)
gstreamer ffmpeg avdec解码数据流向分析
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
php artisan
php artisan
My 2020 summary "don't love the past, indulge in moving forward"
TypeScript let與var的區別
La différence entre le let Typescript et le Var
IP home online query platform
II. D3.js draw a simple figure -- circle
Arduino Serial系列函数 有关print read 的总结
Hash table, generic
Laravel frame step pit (I)
10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
萬卷書 - 價值投資者指南 [The Education of a Value Investor]