Languages

JavaScript interview questions

Beta

Closures, the event loop, prototypes, promises and the quirks that trip people up in front-end loops.

80 questions · 40 theory · 40 coding

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 splits items into consecutive chunks of length size. The last chunk may be shorter if items doesn't divide evenly. If size is 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 at records[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.map do differently from .forEach? And what does .filter do? Walk me through what each one returns.

  • CodingJuniorError handling

    Write entryPoint(a, b) that divides a by b, safely.

    Internally: throw an Error with message "invalid input" if a or b is not a finite number (use Number.isFinite). Otherwise, throw an

  • TheoryJuniorError handling

    Walk me through what try, catch and finally each do in JavaScript. If a function has a return inside try and another return inside finally, which one wins?

  • CodingJuniorMaps, Sets & WeakMaps

    Write entryPoint(items) that counts how many times each value in the array items occurs, and returns the counts as a plain object mapping the string form of each value to its count (so a number 1 and the string "1" count toward the same key). Build the counts with a Map