All 46 questions

  1. 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.
    JavaScript
    console.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?”
  2. 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.
    JavaScript
    console.log(5 == "5");         // true
    console.log(5 === "5");        // false
    console.log(null == undefined);  // true
    console.log(null === undefined); // false

    What 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?”
  3. 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.
    JavaScript
    console.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.”
  4. 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?”
  5. 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?”
  6. 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?”
  7. 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.
    JavaScript
    console.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?”
  8. 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?”
  9. 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?”
  10. 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?”
  11. 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?”
  12. 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

  13. Why is JavaScript mainly used on websites?

    Asked in 2 of 228 interviews · last asked Sep 17 · Concept · Junior

  14. 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?”
  15. 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+?”
  16. How do null and undefined behave with == versus === comparisons?

    Asked once · last asked Jun 7 · Concept · Mid-level

  17. 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

  18. How does JavaScript execute code, and what happens behind the scenes?

    Asked once · last asked Jun 24 · Concept · Mid-level

  19. 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

  20. 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

  21. What does Symbol.unscopables do?

    Asked once · last asked Nov 5 · Concept · Senior

  22. 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

  23. What is the difference between JavaScript expressions and Angular expressions?

    Asked once · last asked Nov 16 · Concept · Mid-level

  24. How can a ternary operator determine which route a product form uses?

    Asked once · last asked Nov 18 · Concept · Junior

  25. What is the JavaScript Symbol type, and what is it used for?

    Asked once · last asked Apr 4 · Concept · Junior

  26. What does the following code snippet do: console.log(11 + 31)?

    Asked once · last asked Apr 13 · Write code · Junior

  27. What is the spread operator in JavaScript?

    Asked once · last asked May 22 · Concept · Junior

  28. What is `let`?

    Asked once · last asked Jun 18 · Concept · Junior

  29. What do you mean by the scope chain?

    Asked once · last asked Jun 24 · Concept · Junior

  30. What is a loop?

    Asked once · last asked Jul 15 · Concept · Junior

  31. What are conditionals?

    Asked once · last asked Jul 15 · Concept · Junior

  32. How do you use try-catch blocks to handle errors?

    Asked once · last asked Aug 4 · Concept · Junior

  33. What is the difference between block scope and function scope?

    Asked once · last asked Aug 4 · Concept · Junior

  34. In JavaScript, what do parseFloat() and parseInt() do, and how do they differ?

    Asked once · last asked Aug 12 · Concept · Junior

  35. Could you briefly explain what a variable actually represents or stores in JavaScript?

    Asked once · last asked Sep 12 · Concept · Junior

  36. 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

  37. What is type coercion?

    Asked once · last asked Sep 29 · Concept · Junior

  38. 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?”
  39. What are the main features and benefits of JavaScript?

    Asked once · last asked Oct 4 · Concept · Junior

  40. What is `try/catch` used for in JavaScript?

    Asked once · last asked Oct 8 · Concept · Junior

  41. What is the difference between a constant and a variable?

    Asked once · last asked Oct 15 · Concept · Junior

  42. Are both let and const block-scoped in JavaScript, or only one of them?

    Asked once · last asked Dec 29 · Concept · Junior

  43. What is the scope of a var declaration in JavaScript?

    Asked once · last asked Dec 29 · Concept · Junior

  44. What does it mean that a variable declared with let can be reassigned?

    Asked once · last asked Jan 20 · Concept · Junior

  45. What is a string in programming?

    Asked once · last asked Oct 25 · Concept · Junior

  46. When would you use `Math.floor` in JavaScript?

    Asked once · last asked Nov 3 · Concept · Junior

More JavaScript 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.