JavaScript Interview Basics: let vs const, Closures and Event Loop

LAB 03 The Interview Lab · Full-Stack Developer

JavaScript basics: 6 questions every full-stack interview asks

Understand var, let and const, == vs ===, hoisting, closures, the event loop and async/await in plain words, with tiny code you can explain out loud.

⏱ 10 min🎯 Freshers & junior devs🧪 4 hands-on drills
Your lab progress0 of 4 drills done
Spot itDecodeBuildTest

Most full-stack interviews start with JavaScript, whether the job uses React, Node.js or Angular. The questions look easy. But interviewers use them to check if you really understand how the language works, or if you only copy code from tutorials.

In this lab you will learn the basics that come up again and again: var, let and const, == vs ===, hoisting, closures, the event loop, and promises vs async/await. Each one starts with an everyday example, then gives the correct technical answer.

The big idea: define it, show it, use it

Every good JavaScript answer has three parts. Use this pattern for any concept they ask.

Step 1
FRAME 1
Define
One clear sentence, no jargon.
Step 2
FRAME 2
Show
A 2 or 3 line example, or its output.
Step 3
FRAME 3
Use
Where it matters in a real app.
Definition, tiny example, real use. Every single time.
Drill 1 · Spot it

Spot the difference

Question: “What is a closure?” Two answers. Switch between them and watch what changes.

A closure is a function inside a function. It is a very important concept in JavaScript and it is used a lot. It is related to scope. Closures are used in many places like React and Node. I have read about closures and I know how to use them in my projects when needed.
✕ Never says what the function remembers
✕ No example to prove understanding
✕ “Used a lot” but no real use case
Drill 2 · Decode

Quick concept check

Guess the answer first. Then tap each card to flip it.

Key concepts, explained simply

Analogy first, then the real answer. Learn these six and you can handle most JavaScript basics rounds.

var, let and constThink of var as a notice for the whole floor, and let or const as a note inside one room. var is function-scoped. let and const are block-scoped, so they live only inside the { } where you declare them. const cannot be re-assigned. Use const by default, let when a value changes, and avoid var.
Hoisting and the TDZLike a teacher reading the class list before the lesson. JavaScript registers declarations before running code. A var starts as undefined. let and const are hoisted too, but using them before their line throws a ReferenceError. That gap is the temporal dead zone (TDZ). Function declarations can be called before they appear.
== vs ===== is “close enough”, === is “exact match”. == (loose equality) converts types first, so 0 == ‘0’ is true. === (strict equality) checks value and type, so 0 === ‘0’ is false. One special case: null == undefined is true, but null === undefined is false.
ClosuresLike a backpack a function carries. When a function is created, it keeps a link to the variables around it. It can use them later, even after the outer function has returned. Closures power private variables, counters, callbacks and React hooks.
The event loopThink of one cashier and a queue. JavaScript runs one thing at a time on the call stack. Slow work like timers and network calls is handled by the browser or Node.js. When it finishes, the callback waits in a queue. When the stack is empty, the event loop runs all microtasks (promise callbacks) first, then the next task (like setTimeout).
Promises vs async/awaitA promise is like a food-delivery order: the food is not here yet, but it will arrive or fail. A promise is pending, then fulfilled or rejected. You handle it with .then() and .catch(). async/await is cleaner syntax built on promises: await pauses only that async function until the promise settles. Use try/catch for errors.
function makeCounter() {
  let count = 0;            // private variable
  return () => ++count;   // closure remembers count
}
const next = makeCounter();
console.log(next(), next()); // 1 2

console.log('A');
setTimeout(() => console.log('B'), 0);
Promise.resolve().then(() => console.log('C'));
console.log('D');            // prints A, D, C, B
💡 In the interview, say the output out loud before you explain it. For example: “It prints A, D, C, B, because promise callbacks run before timers.”
Drill 3 · Build

Build your concept answer

Fill the blanks. Your answer writes itself on the right.

Your answer
Start typing on the left and your answer will appear here.
⏱ ~0 seconds spoken0 words

Three model answers to common JS questions

Read each one aloud. Notice the define, show, use pattern in every answer.

“var is function-scoped and can be declared again, so it can leak out of an if block or a for loop. let and const are block-scoped, so they stay inside the curly braces where they are declared. const also cannot be re-assigned, though an object inside it can still change. In my projects I use const by default, let for values that change, and I avoid var. This prevents bugs like one loop variable being shared by every callback.”

Four mistakes that cost freshers the JS round

Saying const means “cannot change”const only blocks re-assignment. You can still push into a const array. Say this clearly and you stand out.
Calling JavaScript multi-threadedYour JS code runs on one main thread. Async work is handled by the browser or Node.js and comes back through the event loop. (Web Workers are a separate, advanced topic.)
Forgetting errors with awaitAn await without try/catch, or a promise without .catch(), can leave errors unhandled. Always say how you handle failures.
Defining but never showingA definition alone sounds memorised. Add a 2 or 3 line example, or explain what a snippet prints.
Drill 4 · Test

Test yourself

Question 1 of 5

0:00

Rehearse before the real thing

Pick one concept, press start and explain it out loud: define it, show a tiny example, say where you used it. The ring turns amber at 60 seconds and red at 90.

Interview Lab · 03
JS basics: say it right
  1. 1let/const: block. var: function
  2. 2Use === not ==
  3. 3Closure = remembered variables
  4. ★Sync, then promises, then timers
worldremotejobs.com@keshav_consults

Screenshot it. Save it. Share it.

Keep this card on your phone and look at it five minutes before your interview.

Share on WhatsApp
Next in the lab
Lab 04 · What Are Your Salary Expectations? Fresher Answer Guide With Examples
Open lab →

Quick answers

Do I need to know ES6 features?

Yes. let and const, arrow functions, template literals, destructuring, spread, classes, modules and promises all came with ES6 (2015). Modern code uses them everywhere, so interviewers expect them.

Will I have to write code live?

Often, yes. Many companies use a shared online editor or a short live coding round. Practise writing small functions without autocomplete and saying the output aloud.

Is JavaScript the same as Java?

No. They are different languages with different designs. The similar name came from marketing in the 1990s. If someone asks, say this calmly; it shows good basics.

What should I study after these basics?

Learn the this keyword, arrow functions, array methods like map, filter and reduce, and the DOM. Then move to React or Node.js. Later labs in this track cover both.

More remote jobs

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *