zhanglintc 最近的时间轴更新
use experimental 'switch';
313 天前
git -c core.sshCommand="ssh -vvv" clone example.repo
348 天前
1. 画小花
2. 还原第一面
3. 远切回回, 接孩子放学, 还原第二层
4. 手法还原
5. 小鱼公式
2022-03-22 22:11:16 +08:00
git config core.commentChar ";"
2021-12-17 21:58:13 +08:00
zhanglintc's repos on GitHub
Ruby · 11 人关注
Mmrz
Mmrz -- Memorize words scheduling by Ebbinghaus forgetting curve. Web Version:
JavaScript · 1 人关注
lhsjlc4
Parking deck sharing
C · 1 人关注
SetWallpaper
Download today's Bing image and set it as wallpaper.
Java · 0 人关注
5th
Android music player
Python · 0 人关注
algorithm
algorithm
Perl · 0 人关注
app-controller
show/start/stop the apps of a server
Python · 0 人关注
auto-commit
auto-commit repo
Python · 0 人关注
Bassoon
Toy server. Toy framework. WSGI.
HTML · 0 人关注
bing
Bing Wallpaper gallery
Vim script · 0 人关注
bluetooth-keyboard.vim
bluetooth-keyboard.vim
HTML · 0 人关注
Chinese-Chess
在线中国象棋 Chinese-Chess:
C++ · 0 人关注
daDoudou
daDoudou game and it's plug-in (separate from SourcePrac)
Shell · 0 人关注
go-installer
shell script to install golang handy
0 人关注
JS-Prac
JavaScript practice project
JavaScript · 0 人关注
katakana-terminator
A browser extension to convert gairaigo (Japanese loan words) back to English
Python · 0 人关注
leetcode
Solutions for LeetCode problems. Analyses see
JavaScript · 0 人关注
lhsjlc4-xcx
xcx of lhsjlc4
Makefile · 0 人关注
makefile
try to learn how to write makefile
Java · 0 人关注
MySpring
Try to implement the basic functions of Spring framework.
PHP · 0 人关注
navi-site
A personal use navigation site
0 人关注
notebook
notebook
0 人关注
OnJava8
《On Java 8》中文版,又名《Java编程思想》 第5版
Python · 0 人关注
pi-script
scripts for my raspberry pi
Python · 0 人关注
pip-installer
install pip handy
Python · 0 人关注
py-snake-ai
Python snake with AI control. Python 贪食蛇, AI 自动控制
Shell · 0 人关注
pyenv-installer
install pyenv handy
Python · 0 人关注
pytunneling
Python module that allows multi-hop SSH tunneling/port-forwarding.
C · 0 人关注
sanguosha
Sanguosha game forked from Master-G/sanguosha
Python · 0 人关注
selectors-py
selectors
0 人关注
shell-manual
manual pages of shell
zhanglintc

zhanglintc

🏢  HPE
V2EX 第 93460 号会员,加入于 2015-01-24 10:52:10 +08:00
9 G 26 S 50 B
Python, Ruby, Batch files.
zhanglintc 最近回复了
@jobmailcn #5 噢,那看来是不行了。第一层就是 HTTP 了。
@krixaar #2 那就是我操作不了 proxyA 的话就没有办法用嵌套了是吧?
71 天前
回复了 zhanglintc 创建的主题 问与答 下面这段 js 代码的输出应该是什么?
@tutou #15 是的是 node 环境。换成 chrome 的确不一样了:

Node:
sleep done
1
2

Chrome:
sleep done
2
1

那意思这个 timer 的时间实际上还是跟具体实现有关是吧?不能一概而论。
72 天前
回复了 zhanglintc 创建的主题 问与答 下面这段 js 代码的输出应该是什么?
@MossFox https://stackoverflow.com/a/34691484/4156036

看起来是给定的 delay 到期后,可能会有一个“事件”或者“中断”发生,然后 JS 引擎会立即处理它(也就是放到微任务)。但是这个暂时没找到资料来证明。

但是如果说 JS 引擎内部有类似的“事件”机制的话,我感觉都能解释通了。

上面的例子:
setTimeout(function(){console.log(1)}, 10)
setTimeout(function(){console.log(2)}, 0)

第一个 10 毫秒后触发事件,第二个立即触发事件,那么自然第二个先入队列。
到时候执行微任务的时候自然就是第二个先打印了。
72 天前
回复了 zhanglintc 创建的主题 问与答 下面这段 js 代码的输出应该是什么?
@MossFox #11 这个字有点多,链接更多,要花点时间再理解理解。

不过我倒是试了下,如果改成这样的话

```
setTimeout(function(){console.log(1)}, 10) // 队列位置 1
sleep();
setTimeout(function(){console.log(2)}, 0) // 队列位置
```

是可以输出 1 ,2 的:
sleep done
1
2
72 天前
回复了 zhanglintc 创建的主题 问与答 下面这段 js 代码的输出应该是什么?
@MossFox @tutou @LancerXu 各位再帮忙看下:

// 这个大概耗时 1.7 秒
function sleep() {
i=0
// do a heavy job
for (let j = 0; j < 1e9; j++) {
i++;
}
console.log("sleep done")
return 3
}

setTimeout(function(){console.log(1)}, 10) // 队列位置 1
setTimeout(function(){console.log(2)}, 0) // 队列位置 2
sleep();

这里认为塞入微队列的顺序应该是书写顺序吧,那么就是 1 在 2 之前。
然后 sleep 是一个耗时操作,测试大概在 1700 毫秒左右。
那么宏队列结束后调用微队列,此时先出栈 1 ,且应该已经超过 10 毫秒,那么 1 可以直接输出。
但是为什么还是先输出的 2 呢?

还是说 setTimeout 的计时是在进入微队列循环操作后才开始考虑计时器的?

期望输出:
sleep done
1
2

实际输出:
sleep done
2
1
73 天前
回复了 zhanglintc 创建的主题 问与答 下面这段 js 代码的输出应该是什么?
先看了 #8 @MossFox 回复的文章,再看 #3 @tutou 和 #7 @LancerXu 的回复就全理解了。
已领,谢谢
google.com/ncr 印象中好使又简单。
关于   ·   帮助文档   ·   博客   ·   nftychat   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   实用小工具   ·   1365 人在线   最高记录 5556   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 23:37 · PVG 07:37 · LAX 16:37 · JFK 19:37
Developed with CodeLauncher
♥ Do have faith in what you're doing.