Interview Q&A · JavaScript · 10 questions in this topic

JavaScript Fundamentals — JavaScript Interview Q&A

All JavaScript topics

The vocabulary every JavaScript interview opens with — what the language is, how it executes, and the engine pipeline. Part of JavaScript Fundamentals · 204 questions in the JavaScript bank.

What is JavaScript?

Answer

JavaScript is a high-level, dynamically typed, interpreted (JIT-compiled) multi-paradigm language — the language of the web, now running on servers (Node.js), desktops and embedded targets via engines like V8, SpiderMonkey and JavaScriptCore.

Created by Brendan Eich in 1995 (first shipped in Netscape), it is standardized as ECMAScript (ES2024 current) with yearly releases. Its design centers on first-class functions, prototype-based objects, and an event-driven concurrency model.

Example

Example.jsjs
// JavaScript reads like the web's mother tongue
const greet = (name) => `Hello, ${name}!`;
console.log(greet("Interviewer")); // Hello, Interviewer!

💡 Name dynamic typing, first-class functions and the event loop in one breath — that trio frames every follow-up.

How does JavaScript code actually execute (engine pipeline)?

Answer

Source is parsed to an AST, compiled to bytecode (Ignition in V8), interpreted — then hot functions are JIT-optimized (TurboFan) with speculative assumptions, deoptimizing if reality differs. There is no manual compile step; the engine tiers up at runtime.

This is why micro-benchmarks lie (warmup matters) and why stable object shapes (hidden classes) run dramatically faster than megamorphic ones.

Key points

  1. 1Parse — source to AST to bytecode.
  2. 2Interpret — baseline execution with profiling.
  3. 3Optimize — JIT hot paths, deopt on violated assumptions.

Example

Example.jsjs
// same-shape objects optimize well:
const p1 = { x: 1, y: 2 };
const p2 = { x: 3, y: 4 }; // same hidden class as p1

💡 Saying interpreted-then-JIT with deoptimization shows engine-level understanding.

Is JavaScript single-threaded? How does concurrency work?

Answer

The language runtime is single-threaded per realm: one call stack, one thing at a time, with concurrency through the event loop (Web Workers / worker_threads add real threads with isolated memory). Async work (timers, I/O, fetch) defers callbacks to task/microtask queues drained between stack frames.

So: no data races on shared objects by default, but long synchronous loops still freeze everything — the classic frozen-UI bug.

Example

Example.jsjs
console.log("a");
setTimeout(() => console.log("b"), 0);
Promise.resolve().then(() => console.log("c"));
console.log("d"); // a d c b (microtasks before macrotasks)

💡 Single-thread plus event-loop-queues is the complete concurrency model in one sentence.

Recommended resourcesAffiliate links · may earn us a commission

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits