Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeout with zero delay #270

Open
narayanasuri opened this issue Jul 11, 2022 · 0 comments
Open

setTimeout with zero delay #270

narayanasuri opened this issue Jul 11, 2022 · 0 comments
Labels
new-example A proposal of the new example

Comments

@narayanasuri
Copy link

Example

setTimeout with 0 for delay

setTimeout(() => {
  console.log("A");
}, 0);

console.log("B");

Explanation

setTimeout being a part of the Web APIs, maintains its own call stack and then pops its callbacks to the callback/task queue. Only when the traditional call stack is empty, does JavaScript refer to the callback queue.

@narayanasuri narayanasuri added the new-example A proposal of the new example label Jul 11, 2022
@narayanasuri narayanasuri changed the title Web APIs / Call Stack Example setTimeout with zero delay Jul 11, 2022
narayanasuri added a commit to narayanasuri/wtfjs that referenced this issue Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-example A proposal of the new example
Projects
None yet
Development

No branches or pull requests

1 participant