Frontend Developer
JavaScript and TypeScript questions
172 questions on JavaScript and TypeScript for frontend developers, easiest first.
Easy 53
- Block scope of leteasy
- Loose vs strict equalityeasy
- Sync code runs before promise callbackseasy
- typeof null and arrayseasy
- Changing a property of a const objecteasy
- Numbers saved in localStorageeasy
- What fetch does on a 404easy
- TypeScript types at runtimeeasy
- Optional chaining on missing dataeasy
- ?? versus || with zeroeasy
- Order of click handlerseasy
- Sorting numbers without a comparatoreasy
- Why 0.1 + 0.2 is not 0.3easy
- Checking for NaNeasy
- Plus and minus with a stringeasy
- Is an empty array truthyeasy
- When a default parameter applieseasy
- Swapping with destructuringeasy
- Rename and default in destructuringeasy
- Rest parameters versus argumentseasy
- Array.from with a lengtheasy
- Typo in a variable nameeasy
- What JSON.stringify leaves outeasy
- replace changes only one matcheasy
- Changing one letter of a stringeasy
- typeof of a functioneasy
- What && and || returneasy
- Resolving a promise twiceeasy
- What .then returnseasy
- Results of Promise.allSettledeasy
- race versus anyeasy
- Awaiting a non-promiseeasy
- Stopping a polling timereasy
- Default and named importseasy
- Parsing a broken JSON stringeasy
- Cancelling a fetcheasy
- A long loop on the main threadeasy
- Hiding a spinner with finallyeasy
- A rejection nobody handleseasy
- Forgetting to await response.jsoneasy
- Where to run a heavy calculationeasy
- Behaviour of script type moduleeasy
- Type inferred from a leteasy
- Narrowing a union with typeofeasy
- Declaring the same interface twiceeasy
- Type of an optional parametereasy
- Pushing to a readonly arrayeasy
- Type of a const stringeasy
- What as const does to an arrayeasy
- A tuple typeeasy
- Result type of findeasy
- A function that returns nothingeasy
- Limiting a prop to fixed valueseasy
Medium 68
- setTimeout vs microtasksmedium
- Closures in a var loopmedium
- Stale value in useEffectmedium
- Debounce vs throttle for searchmedium
- Arrow function as an object methodmedium
- One failed request breaks the dashboardmedium
- What an async function returnsmedium
- Function hoisting and letmedium
- Spread copies only one levelmedium
- unknown versus anymedium
- reduce on an empty arraymedium
- typeof before a let declarationmedium
- Reading a var before it is setmedium
- Two counters from one factorymedium
- Keeping a balance privatemedium
- this in a plain function callmedium
- Calling bind twicemedium
- Property found on the prototypemedium
- Arrow field versus class methodmedium
- null compared looselymedium
- Adding two arraysmedium
- Freezing a nested configmedium
- What structuredClone cannot copymedium
- Objects as keys in a plain objectmedium
- Attaching data to DOM nodesmedium
- map over new Array(3)medium
- slice versus splicemedium
- for...in over an arraymedium
- Number versus parseInt on "12px"medium
- includes versus indexOf with NaNmedium
- Return value with finallymedium
- When the executor runsmedium
- A chain after catchmedium
- Order of Promise.all resultsmedium
- Reading pages with for awaitmedium
- Error inside a setTimeout callbackmedium
- Total wait with exponential backoffmedium
- Timing a JavaScript animationmedium
- Loading a chart library on clickmedium
- An imported let that changesmedium
- __dirname in an ES modulemedium
- nextTick versus promise in Nodemedium
- Wrapping an error with a causemedium
- Adding a timeout to fetchmedium
- Listener that will not go awaymedium
- Passive touch listenersmedium
- Handler that should run oncemedium
- When Promise.any rejectsmedium
- An endless chain of microtasksmedium
- Resolving with two valuesmedium
- What Promise.withResolvers givesmedium
- Inferring a generic typemedium
- Constraining a genericmedium
- A typed getter with keyofmedium
- Type for a PATCH bodymedium
- A tax-rate lookup tablemedium
- Narrowing on a kind fieldmedium
- A function that narrows a typemedium
- Narrowing with the in operatormedium
- The ! after a valuemedium
- satisfies versus a type annotationmedium
- Reusing a function’s return typemedium
- Passing an object with extra fieldsmedium
- Indexing with noUncheckedIndexedAccessmedium
- Unwrapping a promise typemedium
- Changing an object in statemedium
- Adding to a list in statemedium
- Removing a row from statemedium
Hard 51
- Race condition in data fetchinghard
- Losing this when a method is extractedhard
- Order of logs around awaithard
- Order of object keyshard
- map with parseInthard
- Exhaustive check with neverhard
- When extra properties are an errorhard
- Comparator that returns a booleanhard
- Closure holding a big arrayhard
- Spreading an object with a getterhard
- Symbol keys and JSONhard
- Object.is and negative zerohard
- Deep merge of user JSONhard
- Sorting orders that tiehard
- Using new on an arrow functionhard
- Checking for a private fieldhard
- Passing values into a generatorhard
- Making an object spreadablehard
- Arguments to a tagged templatehard
- Proxy set trap that returns nothinghard
- arguments inside an arrow functionhard
- Adding a BigInt and a numberhard
- Class getter and hasOwnPropertyhard
- return versus return await in tryhard
- A promise awaited too latehard
- Breaking out of for awaithard
- Progress bar that never moveshard
- Sending a callback to a workerhard
- ArrayBuffer after transferhard
- Relying on FinalizationRegistryhard
- setImmediate inside an I/O callbackhard
- A debounce that never debounceshard
- Time with a concurrency limithard
- Throwing after resolvehard
- Top-level await in a config modulehard
- Promise.resolve of a promisehard
- Breaking up a long taskhard
- try/catch around forEach with asynchard
- A conditional type over a unionhard
- Extracting a type with inferhard
- Removing optional and readonlyhard
- Building handler names from keyshard
- Method versus property function typeshard
- Stopping mixed-up string IDshard
- A const type parameterhard
- Type of the catch variablehard
- Typing a global on windowhard
- What the {} type acceptshard
- Old value after an awaithard
- useEffect(async () => ...)hard
- A custom hook with a stale callbackhard