ES6+medium

JavaScript fundamentals checklist for frontend interviews

Walk through the JavaScript fundamentals a frontend engineer should know: scope, closures, hoisting, equality, `this`, prototypes, async behavior, modules, and common runtime pitfalls.

Asked at Tenable

#JavaScript#fundamentals#closures#this#async

Answer

Interview framing: This is usually a breadth question. Give a structured checklist and show that you can connect language rules to real bugs.

Core topics:

  1. Scope and closures:
  • let/const are block-scoped; var is function-scoped.
  • A closure lets a function remember variables from its outer scope.
  • Common use cases: event handlers, memoization, debounce, private state.
  1. Hoisting and TDZ:
  • Function declarations are callable before their declaration.
  • var is hoisted and initialized to undefined.
  • let/const are hoisted but unavailable until initialized (temporal dead zone).
  1. Equality and coercion:
  • Prefer === because it avoids implicit coercion.
  • Know common surprises: [] == false, '0' == 0, null == undefined.
  1. this binding:
  • Determined by call site: default, implicit, explicit call/apply/bind, or new.
  • Arrow functions do not have their own this; they capture lexical this.
  1. Prototypes and classes:
  • Classes are syntax over prototype-based inheritance.
  • Property lookup walks the prototype chain.
  1. Async model:
  • Synchronous code runs first.
  • Promise callbacks run as microtasks.
  • Timers, events, and network callbacks are macrotasks.
  1. Common frontend pitfalls:
  • Mutating shared objects accidentally.
  • Missing return in promise chains.
  • Forgetting cleanup for timers/listeners.
  • Relying on stale closure values in callbacks.

Strong closing sentence: "I try to explain JS fundamentals by tying them to production bugs: stale state, wrong this, race conditions, memory leaks, and unexpected async ordering."

Source: Tenable frontend prep

Practise more ES6+ questions →