当前位置:网站首页>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>
边栏推荐
- PHP install composer
- Arduino Serial系列函数 有关print read 的总结
- Flask Foundation
- 萬卷書 - 價值投資者指南 [The Education of a Value Investor]
- [set theory] partition (partition | partition example | partition and equivalence relationship)
- Distributed ID
- centos php7.3安装redis扩展
- [solved] sqlexception: invalid value for getint() - 'Tian Peng‘
- SecureCRT password to cancel session recording
- LeetCode
猜你喜欢
3311. Longest arithmetic
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
SecureCRT取消Session记录的密码
Hash table, generic
My 2020 summary "don't love the past, indulge in moving forward"
Use the jvisualvm tool ----- tocmat to start JMX monitoring
[solved] sqlexception: invalid value for getint() - 'Tian Peng‘
File operation serialization recursive copy
Final, override, polymorphism, abstraction, interface
3311. 最长算术
随机推荐
3311. Longest arithmetic
TypeScript let与var的区别
4279. Cartesian tree
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
La différence entre le let Typescript et le Var
Final, override, polymorphism, abstraction, interface
docker建立mysql:5.7版本指定路径挂载不上。
IP home online query platform
树莓派更新工具链
Advanced API (UDP connection & map set & collection set)
Use of framework
4everland: the Web3 Developer Center on IPFs has deployed more than 30000 dapps!
《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
Raspberry pie update tool chain
How to plan well?
Interfaces and related concepts
LeetCode
"Baidu Cup" CTF game 2017 February, Web: blast-1
C WinForm framework
2021 year end summary