(function(){
// 아래 JS 코드는 "비동기 이벤트" 코드 블록이 아니므로 큐에 쌓이지 않으며, Blocking 또한 되지 않는다.
for (var i = 0; i < 10000; i++){
console.log('javascript block');
}
// 첫 번째 비동기 이벤트(load)
this.onload = function(){
console.log('load eventhandler block queue1');
// 두 번째 비동기 이벤트(click)
this.onclick = function(){
console.log('click event handler block queue2=' + new Date().getTime());
// 세 번째 비동기 이벤트(timeout)
this.setTimeout(function(){
for (var i = 0; i < 10; i++){
console.log('timout event block queue3=' + new Date().getTime());
}
}, 1);
var args = arguments;
// 네 번째 비동기 이벤트(interval)
args.callee.timer1 = this.setInterval(function(){
for (var i = 0; i < 100; i++){
console.log('inerval event block queue4=' + new Date().getTime());
}
// inerval 타이머 이벤트를 종료 시킨다.
this.clearInterval(args.callee.timer1);
}, 1);
// 다섯 번째 비동기 이벤트(interval)
args.callee.timer2 = this.setInterval(function(){
for (var i = 0; i < 10; i++){
console.log('inerval event block queue5=' + new Date().getTime());
}
this.clearInterval(args.callee.timer2);
}, 1);
}
}
})();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.