1
Arrowing 2014 年 11 月 6 日
同步的,不阻塞,个人理解。
alert这个才是阻塞的吧 |
2
skydiver 2014 年 11 月 6 日 via Android
同步的……阻塞是说的IO,没IO哪来阻塞
|
3
meteor 2014 年 11 月 6 日
|
5
yyfearth 2014 年 11 月 6 日
当然是同步的了 JS下面还没有parallel循环的支持
JS本身单线程 所以没有IO的部分都是同步执行的 就算用了setTimeout也是执行完了一个才可能开始下一个 |
6
yyfearth 2014 年 11 月 6 日
如果想做到异步而且是并行循环 那么得用worker来实现了
|
10
alsotang 2014 年 11 月 6 日
是
|
11
Arrowing 2014 年 11 月 6 日 @cxe2v 我就这个问题做了测试,将以下代码放置html文件跑起来便知
<div id="test" style="width: 50px;height: 50px;background:#000;position: absolute;left: 0; top: 0;"> </div> <script> var test = document.getElementById('test'); setInterval(function(){ test.style.left = (parseInt(test.style.left) + 1) + 'px'; test.style.top = (parseInt(test.style.top) + 1) + 'px'; }, 10); setTimeout(function(){ alert('stop'); }, 1000); </script> |