← Back to JavaScript Course | Chapter 12: Reference & Interview | Lesson 5 of 9

JS Interview Questions

Basic Interview Questions

Common opening interview questions probe fundamentals like the difference between var/let/const, how == differs from ===, and what undefined versus null actually mean, since these reveal how solid someone's grasp of the basics really is.

Example: Basic Interview Questions

javascript
console.log(typeof undefined, typeof null); // classic var/let/const & null-vs-undefined question
console.log(1 == "1", 1 === "1");

Functions and Scope

Function and scope questions often ask you to explain closures, hoisting, or what this refers to in different call contexts — areas where JavaScript's behavior surprises many developers.

Example: Functions and Scope

javascript
function outer() {
  let count = 0;
  return () => ++count; // closures question
}
const counter = outer();
console.log(counter(), counter());

Arrays and Objects

Array and object questions typically involve manipulating data with map/filter/reduce, explaining shallow vs. deep copies, or predicting output involving reference vs. value semantics.

Example: Arrays and Objects

javascript
const nums = [1, 2, 3];
const doubled = [...nums].map(n => n * 2); // shallow copy question
console.log(nums, doubled);

Async JavaScript

Async JavaScript questions usually cover the event loop, the difference between microtasks and macrotasks, and converting callback-based or Promise-chain code to async/await.

Example: Async JavaScript

javascript
console.log("1");
setTimeout(() => console.log("2 - macrotask"), 0);
Promise.resolve().then(() => console.log("3 - microtask"));
console.log("4"); // classic event loop ordering question

Coding Interview Practice

Practicing timed coding problems that combine these concepts — not just reading about them — is what actually builds the speed and confidence needed in a live interview setting.

Example: Coding Interview Practice

javascript
function getValue(cb) { setTimeout(() => cb(42), 100); }
async function getValueAsync() {
  return new Promise(resolve => setTimeout(() => resolve(42), 100));
}
getValueAsync().then(v => console.log(v));
🔒

Chapter Quiz — Complete all 9 topics to unlock

0/9 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.