JavaScript interview questions
BetaClosures, the event loop, prototypes, promises and the quirks that trip people up in front-end loops.
Subtopics
- Types, coercion & equality7
- Scope, hoisting & closures7
- this, call, apply & bind7
- Prototypes & classes7
- Promises & async/await7
- The event loop & microtasks7
- Arrays & iteration methods7
- Objects, destructuring & spread7
- Modules (ESM vs CommonJS)6
- Error handling6
- Maps, Sets & WeakMaps6
- Regular expressions & strings6
Sample questions
- CodingJuniorArrays & iteration methods
Write
entryPoint(items, size)that splitsitemsinto consecutive chunks of lengthsize. The last chunk may be shorter ifitemsdoesn't divide evenly. Ifsizeis less than 1, return an empty array. Return the chunks as an array of arrays, in the original order. - CodingJuniorArrays & iteration methods
Write
entryPoint(records, key)that groups an array of plain objects by the value atrecords[i][key]. Return a plain object whose keys are the group values converted to strings, and whose values are arrays of the original records, in their original relative order. Records whose - TheoryJuniorArrays & iteration methods
What does
Array.prototype.mapdo differently from.forEach? And what does.filterdo? Walk me through what each one returns. - CodingJuniorError handling
Write
entryPoint(a, b)that dividesabyb, safely.Internally: throw an
Errorwith message"invalid input"ifaorbis not a finite number (useNumber.isFinite). Otherwise, throw an - TheoryJuniorError handling
Walk me through what
try,catchandfinallyeach do in JavaScript. If a function has areturninsidetryand anotherreturninsidefinally, which one wins? - CodingJuniorMaps, Sets & WeakMaps
Write
entryPoint(items)that counts how many times each value in the arrayitemsoccurs, and returns the counts as a plain object mapping the string form of each value to its count (so a number1and the string"1"count toward the same key). Build the counts with aMap