当前位置:网站首页>专题 | 同步 异步
专题 | 同步 异步
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>
边栏推荐
猜你喜欢
Win 10 find the port and close the port
[HCAI] learning summary OSI model
[set theory] partition (partition | partition example | partition and equivalence relationship)
Inno Setup 制作安装包
Liang Ning: 30 lectures on brain map notes for growth thinking
多个全局异常处理类,怎么规定执行顺序
Deep learning parameter initialization (I) Xavier initialization with code
691. Cube IV
Summary of abnormal mechanism of interview
File operation serialization recursive copy
随机推荐
File operation serialization recursive copy
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
Practice of enterprise ab/testing platform
[solved] win10 cannot find a solution to the local group policy editor
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
[cmake] cmake link SQLite Library
Summary of abnormal mechanism of interview
Advanced API (serialization & deserialization)
Architecture notes
Inno Setup 制作安装包
File links cannot be opened or downloaded in Google browser
[most detailed] latest and complete redis interview book (50)
[plus de détails] dernière entrevue complète redis (50)
Final, override, polymorphism, abstraction, interface
LeetCode
Setting up the development environment of dataworks custom function
Arduino 软串口通信 的几点体会
dataworks自定义函数开发环境搭建
Hash table, generic
691. Cube IV