Refer to code below:
console.log(0);
setTimeout(() => {
console.log(1);
});
console.log(2);
setTimeout(() => {
console.log(3);
}, 0);
console.log(4);
In which sequence will the numbers be logged?
https://onecompiler.com/javascript/3yncbmub3
3yncbmub3 - JavaScript - OneCompiler
Javascript Online Compiler Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is
onecompiler.com
javascript 동작 원리 : setTimeout() 함수가 나오면 나중에 실행시키도록 뒤로 빼놓음.
https://www.youtube.com/watch?v=v67LloZ1ieI