All 46 questions
How do var, let, and const differ in scope, reassignment, hoisting, and the temporal dead zone?
Asked in 23 of 228 interviews · last asked Nov 10 · Concept · Junior
Show answer
Inside functions, `var` is function-scoped; `let` and `const` are block-scoped. `var` and `let` allow reassignment; `const` does not. All three are hoisted, but only `var` starts as `undefined`. `let` and `const` remain inaccessible in the temporal dead zone until initialization.
- At the top level, `var` is global in scripts but module-scoped in modules.
- `const` prevents reassignment, not changes to an object's properties or an array's contents.
- `var` allows repeated declarations; `let` and `const` cannot be redeclared in the same scope.
- Prefer `const`; use `let` when reassignment is needed. Avoid `var` in new code.
JavaScriptconsole.log(a); // undefined var a = 1; try { console.log(b); } catch (error) { console.log(error.name); // ReferenceError } let b = 2; const item = { value: 1 }; item.value = 2; // Allowed: item still refers to the same object.What the interviewer checks: The interviewer checks whether you understand scope, binding changes, and access before initialization.
Common mistake (in 4 of 9 reviewed answers): Many answers forget that hoisting is not initialization: `let` and `const` are hoisted but cannot be accessed before initialization.
Other ways it was asked
- “What is the difference between var, let, and const in JavaScript?”
- “What is the difference between var, let, and const?”
- “In JavaScript, can you differentiate between let, var, and const?”
What is the difference between == and === in JavaScript, and when would you use each?
Asked in 14 of 228 interviews · last asked Nov 6 · Concept · Junior
Show answer
=== compares values without converting their types. == may convert types before comparing, so values of different types can be equal. Use === by default for predictable comparisons. Use == only when you want its conversion rules, such as value == null to check for null or undefined.
- === returns false when the operands have different types.
- == can produce surprising results, such as 0 == false being true.
- Both operators compare objects by reference, not by their contents.
- NaN is not equal to itself with either operator.
JavaScriptconsole.log(5 == "5"); // true console.log(5 === "5"); // false console.log(null == undefined); // true console.log(null === undefined); // falseWhat the interviewer checks: The interviewer is checking whether you understand type conversion and can choose comparisons that avoid unexpected results.
Other ways it was asked
- “In JavaScript, what is the difference between == and ===?”
- “What is the difference between == and === in JavaScript?”
- “What is the difference between `==` and `===` in JavaScript?”
What is hoisting in JavaScript, and how does it affect var, let, and const?
Asked in 10 of 228 interviews · last asked Oct 21 · Concept · Junior
Show answer
Hoisting means JavaScript sets up declarations before running code in their scope; it does not move the code. A var variable starts as undefined, so you can read it before its declaration. let and const are also hoisted, but reading them before their declarations run throws a ReferenceError. This waiting period is called the temporal dead zone.
- var has function, module, or global scope; let and const have block scope.
- Initializers run where they appear in the code, not during hoisting.
- const must have an initializer in a normal declaration and cannot be reassigned.
JavaScriptconsole.log(count); // undefined var count = 3; { console.log(total); // ReferenceError: temporal dead zone let total = 5; }What the interviewer checks: The interviewer checks whether you can explain scope, initialization, and access before a declaration.
Other ways it was asked
- “What is hoisting in JavaScript?”
- “What is hoisting?”
- “Tell me about hoisting in JavaScript.”
What is JavaScript?
Asked in 8 of 228 interviews · last asked Sep 24 · Concept · Junior
Show answer
JavaScript is a programming language used to make web pages interactive. It handles user actions, updates page content, and requests data without reloading the page. It also runs outside browsers, such as on servers using Node.js.
- HTML defines page structure, CSS controls appearance, and JavaScript adds behavior.
- JavaScript is dynamically typed: values have types, but variables are not fixed to one type.
- JavaScript and Java are different languages.
What the interviewer checks: The interviewer is checking whether you understand JavaScript’s role on the web and where else it runs.
Other ways it was asked
- “What is JavaScript? Explain it.”
- “What is JavaScript, and why is it used?”
What is the difference between Java and JavaScript?
Asked in 7 of 228 interviews · last asked Nov 14 · Concept · Junior
Show answer
Java and JavaScript are different programming languages, despite their similar names. Java uses static types and usually runs on the Java Virtual Machine (JVM). JavaScript uses dynamic types and runs in browsers or runtimes like Node.js. I would use Java for many backend or Android projects, and JavaScript for interactive web pages or Node.js backends.
- Java checks types before execution; JavaScript checks types at runtime.
- Java uses class-based inheritance; JavaScript uses prototype-based inheritance, even with class syntax.
- Both can run on servers; JavaScript is the standard language for browser scripting.
What the interviewer checks: The interviewer is checking whether you can distinguish their type systems, runtimes, and common uses.
Other ways it was asked
- “What is the difference between Java and JavaScript, and when would you use each?”
- “What is the difference between JavaScript and Java?”
What’s the difference between null and undefined?
Asked in 5 of 228 interviews · last asked Sep 2 · Concept · Junior
Show answer
In JavaScript, `undefined` usually means a variable has no assigned value or a property is missing. `null` is normally set on purpose to mean “no value.” Both are primitive values, but they have different types.
- You can also explicitly assign `undefined`; it is not only produced automatically.
- `typeof undefined` returns `"undefined"`; `typeof null` returns `"object"` because of a historical JavaScript bug.
- `null == undefined` is true, but `null === undefined` is false.
What the interviewer checks: The interviewer is checking whether you understand missing values, intentional absence, and JavaScript’s type and equality rules.
Other ways it was asked
- “What is the difference between null and undefined?”
- “What is the difference between null and undefined in JavaScript?”
- “What is the difference between undefined and null?”
What is the temporal dead zone, and how does it differ from accessing a hoisted var?
Asked in 4 of 228 interviews · last asked Sep 29 · Concept · Mid-level
Show answer
The temporal dead zone is the time from entering a scope until a `let` or `const` binding is initialized. Accessing it during this time throws a `ReferenceError`. A hoisted `var` starts as `undefined`, so reading it before any assignment returns `undefined`.
- `let` and `const` are hoisted, but remain uninitialized during the temporal dead zone.
- Even `typeof` throws a `ReferenceError` for a variable in its temporal dead zone.
- A `let` declaration without an initializer sets the variable to `undefined` when that declaration runs.
JavaScriptconsole.log(a); // undefined var a = 1; console.log(b); // ReferenceError: b is in its temporal dead zone let b = 2;What the interviewer checks: The interviewer is checking whether you distinguish hoisting from initialization and know when variable access throws an error.
Other ways it was asked
- “How would you explain the practical difference between a hoisted var being initialized to undefined and the temporal dead zone for let and const?”
- “How does the temporal dead zone affect access to a `let` or `const` variable before its declaration?”
- “What is the temporal dead zone?”
What are the different data types in JavaScript?
Asked in 3 of 228 interviews · last asked Oct 25 · Concept · Junior
Show answer
JavaScript has seven primitive types: string, number, bigint, boolean, undefined, symbol, and null. The non-primitive type is object, which includes arrays, functions, and dates.
- Primitive values are immutable. Objects can be changed.
- typeof null returns "object", but null is a primitive.
- Functions are objects, but typeof returns "function" for them.
- TypeScript adds compile-time types, such as unions and interfaces, without adding new runtime data types.
What the interviewer checks: The interviewer is checking whether you know the primitive types and how they differ from objects.
Other ways it was asked
- “What data types are available in JavaScript and TypeScript?”
- “What data types are available in JavaScript?”
- “What are non-primitive data types in JavaScript?”
Are let and const hoisted, and what happens if you access them before their declarations?
Asked in 2 of 228 interviews · last asked Apr 27 · Concept · Mid-level
Other ways it was asked
- “Are variables declared with `let` hoisted in JavaScript, and how does that work?”
- “How does hoisting work with let and const in JavaScript?”
What types of scope exist in JavaScript?
Asked in 2 of 228 interviews · last asked Oct 30 · Concept · Junior
Other ways it was asked
- “What is scope in JavaScript?”
What is a JavaScript variable?
Asked in 2 of 228 interviews · last asked Sep 12 · Concept · Junior
Other ways it was asked
- “What is a variable in JavaScript?”
How can you print the value of a variable to the console in JavaScript?
Asked in 2 of 228 interviews · last asked Sep 17 · Tooling · Junior
Why is JavaScript mainly used on websites?
Asked in 2 of 228 interviews · last asked Sep 17 · Concept · Junior
Can you explain what JavaScript is and where it is used?
Asked in 2 of 228 interviews · last asked Oct 30 · Concept · Junior
Other ways it was asked
- “Can you explain JavaScript?”
What changed from ES5 to ES6?
Asked in 2 of 228 interviews · last asked Jun 18 · Concept · Junior
Other ways it was asked
- “What changes were introduced in ECMAScript 6?”
- “What is ES6+?”
How do null and undefined behave with == versus === comparisons?
Asked once · last asked Jun 7 · Concept · Mid-level
If a variable is declared outside a block and a same-named `let` variable is declared inside it, what happens, and what is printed inside and outside the block?
Asked once · last asked Jun 18 · Scenario · Junior
How does JavaScript execute code, and what happens behind the scenes?
Asked once · last asked Jun 24 · Concept · Mid-level
In a complex JavaScript application, when would you still choose var, if ever, and what safeguards would you use to avoid bugs caused by unexpected undefined values?
Asked once · last asked Jul 27 · Scenario · Senior
What is the nullish coalescing operator, and how is it safer than the logical OR operator when zero is a valid value?
Asked once · last asked Sep 15 · Concept · Junior
What does Symbol.unscopables do?
Asked once · last asked Nov 5 · Concept · Senior
Can you write a console statement that checks whether 0.1 + 0.2 is strictly equal to 0.3?
Asked once · last asked Nov 10 · Write code · Junior
What is the difference between JavaScript expressions and Angular expressions?
Asked once · last asked Nov 16 · Concept · Mid-level
How can a ternary operator determine which route a product form uses?
Asked once · last asked Nov 18 · Concept · Junior
What is the JavaScript Symbol type, and what is it used for?
Asked once · last asked Apr 4 · Concept · Junior
What does the following code snippet do: console.log(11 + 31)?
Asked once · last asked Apr 13 · Write code · Junior
What is the spread operator in JavaScript?
Asked once · last asked May 22 · Concept · Junior
What is `let`?
Asked once · last asked Jun 18 · Concept · Junior
What do you mean by the scope chain?
Asked once · last asked Jun 24 · Concept · Junior
What is a loop?
Asked once · last asked Jul 15 · Concept · Junior
What are conditionals?
Asked once · last asked Jul 15 · Concept · Junior
How do you use try-catch blocks to handle errors?
Asked once · last asked Aug 4 · Concept · Junior
What is the difference between block scope and function scope?
Asked once · last asked Aug 4 · Concept · Junior
In JavaScript, what do parseFloat() and parseInt() do, and how do they differ?
Asked once · last asked Aug 12 · Concept · Junior
Could you briefly explain what a variable actually represents or stores in JavaScript?
Asked once · last asked Sep 12 · Concept · Junior
How does == perform type coercion before comparing in JavaScript, how does === compare without type conversion, and what example illustrates the difference?
Asked once · last asked Sep 17 · Concept · Junior
What is type coercion?
Asked once · last asked Sep 29 · Concept · Junior
In JavaScript, what exactly is constant about a variable declared with const?
Asked once · last asked Oct 3 · Concept · Junior
Other ways it was asked
- “What exactly is constant about const?”
What are the main features and benefits of JavaScript?
Asked once · last asked Oct 4 · Concept · Junior
What is `try/catch` used for in JavaScript?
Asked once · last asked Oct 8 · Concept · Junior
What is the difference between a constant and a variable?
Asked once · last asked Oct 15 · Concept · Junior
Are both let and const block-scoped in JavaScript, or only one of them?
Asked once · last asked Dec 29 · Concept · Junior
What is the scope of a var declaration in JavaScript?
Asked once · last asked Dec 29 · Concept · Junior
What does it mean that a variable declared with let can be reassigned?
Asked once · last asked Jan 20 · Concept · Junior
What is a string in programming?
Asked once · last asked Oct 25 · Concept · Junior
When would you use `Math.floor` in JavaScript?
Asked once · last asked Nov 3 · Concept · Junior
More JavaScript interview questions
- All JavaScript interview questions
- JavaScript Async and Event Loop Interview Questions
- React, Redux and RxJS Interview Questions
- Node.js, TypeScript and JavaScript Tooling Interview Questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every JavaScript interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
228 interviews, 160 candidates, Nov 2025 to Nov 2026. Updated every month with new interviews.
Or add the Chrome extension