JavaScript & TypeScript
Scope, closures, async behavior, object identity, and the type system.
What is a closure?
A closure is a function together with access to the variables in the scope where it was created. That access remains available even after the outer function has finished running. Closures are useful for private state, callbacks and functions configured with some remembered value.
How does this work? How are arrow functions different?
this is the receiver used when a regular function runs, and its value usually depends on how the function is called. Arrow functions do not create their own this; they use the surrounding one. This matters when a method is passed as a callback and loses its original receiver.
How do prototypes and classes work?
A prototype is an object from which another object can inherit properties and methods. When a property is missing on an object, JavaScript follows its prototype chain until it finds the property or reaches null. Classes provide structured syntax for constructing objects and sharing methods through that mechanism.
Is spread a deep copy?
Spread syntax creates a new outer object or array by copying its enumerable contents. It is a shallow copy, so nested objects are still shared references. This matters when updating React state or copying request data that another part of the application may modify.
Debounce vs throttle: what is the difference?
Debouncing and throttling control how frequently a function runs when events arrive repeatedly. Debouncing waits for a quiet period, while throttling limits execution frequency during continued activity. They reduce unnecessary work but introduce different delays and must match the user experience.
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.