当前位置:网站首页>Topic | synchronous asynchronous
Topic | synchronous asynchronous
2022-07-03 07:19:00 【Happy happy learning code】
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>
Still don't understand promise Purpose
6. This classic , Change position casually, understand
<!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>
边栏推荐
猜你喜欢
IP home online query platform
JMeter JSON extractor extracts two parameters at the same time
[vscode - vehicle plug-in reports an error] cannot find module 'xxx' or its corresponding type declarations Vetur(2307)
My 2020 summary "don't love the past, indulge in moving forward"
Common APIs
Win 10 find the port and close the port
Hash table, generic
“百度杯”CTF比赛 2017 二月场,Web:爆破-1
Pat grade a real problem 1166
[HCAI] learning summary OSI model
随机推荐
docker建立mysql:5.7版本指定路径挂载不上。
Interview questions about producers and consumers (important)
[set theory] partition (partition | partition example | partition and equivalence relationship)
Basic knowledge about SQL database
dataworks自定义函数开发环境搭建
691. 立方体IV
How to specify the execution order for multiple global exception handling classes
Advanced API (use of file class)
PAT甲级真题1166
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
2021 year end summary
Advanced API (byte stream & buffer stream)
萬卷書 - 價值投資者指南 [The Education of a Value Investor]
centos php7.2.24升级到php7.3
Book recommendation~
Arduino 软串口通信 的几点体会
TCP cumulative acknowledgement and window value update
[plus de détails] dernière entrevue complète redis (50)
The difference between typescript let and VaR
VMware virtual machine installation