Explain the event loop including the call stack and callback queue.
Simple meaning
Synchronous code runs on the call stack until it is empty.
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready Frontend Master questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
Synchronous code runs on the call stack until it is empty.
Open the full page for Why, Steps, Example and Key takeaway.
Microtasks include Promise callbacks and queueMicrotask and they flush completely before the next macrotask.
Open the full page for Why, Steps, Example and Key takeaway.
Objects have an internal prototype link used when a property is missing.
Open the full page for Why, Steps, Example and Key takeaway.
It is the walk from an object to Object.prototype and then null while looking up a property.
Open the full page for Why, Steps, Example and Key takeaway.
I keep a timeout id, clear it on every call, and set a new timeout that fires the original function after wait ms.
Open the full page for Why, Steps, Example and Key takeaway.
Call and apply invoke the function now with a chosen this
Open the full page for Why, Steps, Example and Key takeaway.
I put one listener on a parent and use event.target to see which child was clicked.
Open the full page for Why, Steps, Example and Key takeaway.
StructuredClone is the modern built-in for many values.
Open the full page for Why, Steps, Example and Key takeaway.
Let and const exist in the scope from the start of the block but cannot be read until the declaration line.
Open the full page for Why, Steps, Example and Key takeaway.
Listeners can run on the way down from window to the target, then on the way up.
Open the full page for Why, Steps, Example and Key takeaway.
Cookies are small, sent with matching requests, and can be HttpOnly so JS cannot steal them.
Open the full page for Why, Steps, Example and Key takeaway.
A non-simple request triggers OPTIONS first.
Open the full page for Why, Steps, Example and Key takeaway.
A page can freely read data only from the same scheme, host, and port.
Open the full page for Why, Steps, Example and Key takeaway.
I pick interface for object shapes that might be extended or merged in declaration files.
Open the full page for Why, Steps, Example and Key takeaway.
I define a Props interface and annotate the function parameter.
Open the full page for Why, Steps, Example and Key takeaway.
Any turns off checking, so I can access any property and hide bugs.
Open the full page for Why, Steps, Example and Key takeaway.
I model idle, loading, success with data, and error with a message as a discriminated union.
Open the full page for Why, Steps, Example and Key takeaway.
It tells you when an element enters the viewport without scroll listeners.
Open the full page for Why, Steps, Example and Key takeaway.
PushState and replaceState change the URL without a full reload, which SPAs use for routing.
Open the full page for Why, Steps, Example and Key takeaway.
All fails fast if any promise rejects, which is good when every request is required.
Open the full page for Why, Steps, Example and Key takeaway.