Interview Q&A / JavaScript
JavaScript interview questions
Closures, the event loop, this, promises and the core language questions every frontend round asks.
Prefer rapid revision? Practise JavaScript short interview answers →
- What is the difference between var, let and const? Explain hoisting and the temporal dead zone.
var is function-scoped and is hoisted with the value undefined. let and const are block-scoped and are hoisted too, but cannot be used before their declaration line; that gap is the temporal dead zone. const also cannot be reassigned, though an object it holds can still be changed.
BeginnerIn-depth3 min read - What is the difference between a function declaration and a function expression?
A declaration is hoisted with its body, so you can call it before the line it appears on. An expression assigns a function to a variable, and the variable follows var, let or const rules, so calling it early fails.
BeginnerQuick answer1 min read