What is the difference between var, let, and const?
Simple meaning
Var is function-scoped and can be redeclared, which surprises people.
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.
Var is function-scoped and can be redeclared, which surprises people.
Open the full page for Why, Steps, Example and Key takeaway.
A closure is a function that remembers variables from the scope where it was created even after that outer function has returned.
Open the full page for Why, Steps, Example and Key takeaway.
Declarations are moved to the top of their scope during compile, so you can call a function declaration before its line.
Open the full page for Why, Steps, Example and Key takeaway.
In a regular function, this depends on how it is called: object method, call or apply, or undefined in strict mode.
Open the full page for Why, Steps, Example and Key takeaway.
Double equals coerces types, so 1 equals true and empty string equals false in some cases.
Open the full page for Why, Steps, Example and Key takeaway.
Undefined means a variable was declared but never given a value, or a missing object property.
Open the full page for Why, Steps, Example and Key takeaway.
The DOM is the browser's tree of nodes built from HTML so JavaScript can read and update the page.
Open the full page for Why, Steps, Example and Key takeaway.
I select the node and call addEventListener with click and a function.
Open the full page for Why, Steps, Example and Key takeaway.
After a handler on the target runs, the event travels up through parents to document.
Open the full page for Why, Steps, Example and Key takeaway.
A Promise represents a value that will arrive later: pending, then fulfilled or rejected.
Open the full page for Why, Steps, Example and Key takeaway.
Async functions always return a Promise.
Open the full page for Why, Steps, Example and Key takeaway.
Debounce waits until the user stops firing an event for N milliseconds, then runs once.
Open the full page for Why, Steps, Example and Key takeaway.
Throttle runs at most once per interval while the event keeps firing, like scroll or mousemove.
Open the full page for Why, Steps, Example and Key takeaway.
Browsers block a page on one origin from reading responses from another origin unless the server sends Access-Control-Allow-Origin.
Open the full page for Why, Steps, Example and Key takeaway.
LocalStorage is for non-sensitive UI preferences, larger, and never sent automatically with requests.
Open the full page for Why, Steps, Example and Key takeaway.
SessionStorage is like localStorage but tied to the tab and cleared when that tab closes.
Open the full page for Why, Steps, Example and Key takeaway.
It catches wrong props, missing fields, and typo-level bugs before the browser.
Open the full page for Why, Steps, Example and Key takeaway.
Both describe object shapes
Open the full page for Why, Steps, Example and Key takeaway.
A union means a value can be one of several types, like string or number, or loading or success or error.
Open the full page for Why, Steps, Example and Key takeaway.
Fetch sends an HTTP request and returns a Promise for the Response.
Open the full page for Why, Steps, Example and Key takeaway.