Facebook Pixel

Explain the event loop with microtasks and macrotasks?

The event loop processes the call stack, then microtasks (promise callbacks), then macrotasks (setTimeout, events), one per loop. Microtasks run after each task and before the next macrotask, which is why promise callbacks run before setTimeout callbacks.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in FAANG-Level JavaScript Interview Questions With Explanations

It does not run immediately. The callback goes to the macrotask queue and runs after the current stack and all microtasks (promise callbacks) complete. setTimeout 0 defers to the next event loop tick, not to the current one.

call and apply call a function with a specific this and arguments (apply takes an array). bind returns a new function with this permanently set. All three are about controlling this explicitly, which is useful when this matters.

Each object has a prototype, which is another object. When you access a property, JS looks on the object, then its prototype, then up the chain until found or reaching null. This is how inheritance works in JS without classes.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.