Day 1: Variables, Scope & Hoisting
Core Questions:
- What are the differences between var, let, and const?
- Follow-up: Can you reassign const objects' properties?
- Follow-up: What happens when you try to access them before declaration?
- Explain hoisting in JavaScript
- Follow-up: How does hoisting work differently for var, let, const, and functions?
- Follow-up: What is the Temporal Dead Zone (TDZ)?
- What is scope in JavaScript? Explain different types of scope
- Follow-up: What is lexical scope?
- Follow-up: How does block scope differ from function scope?
Output-Based Questions:
// Q1: What will be the output?
console.log(x);
var x = 5;
console.log(x);
// Q2: What will be the output?
console.log(a);
let a = 10;
// Q3: What will be the output?
function test() {
console.log(y);
var y = 20;
}
test();
// Q4: What will be the output?
let x = 10;
{
console.log(x);
let x = 20;
}
// Q5: What will be the output?
const obj = { name: 'John' };
obj.name = 'Jane';
console.log(obj.name);
obj = { name: 'Bob' }; // What happens?
Day 2: Data Types & Type Coercion
Core Questions:
- What are the primitive and non-primitive data types in JavaScript?
- Follow-up: What is the difference between primitive and reference types?
- Follow-up: How are they stored in memory?
- Explain type coercion in JavaScript
- Follow-up: What is the difference between == and ===?
- Follow-up: When does implicit vs explicit coercion happen?
- What is NaN? How do you check if a value is NaN?
- Follow-up: Why does NaN === NaN return false?
- Follow-up: What's the difference between isNaN() and Number.isNaN()?
Output-Based Questions:
// Q1: What will be the output?
console.log(typeof null);
console.log(typeof undefined);
console.log(typeof NaN);
// Q2: What will be the output?
console.log(1 + "2" + "2");
console.log(1 + +"2" + "2");
console.log(1 + -"1" + "2");
// Q3: What will be the output?
console.log("5" - 3);
console.log("5" + 3);
console.log([] + []);
console.log([] + {});
console.log({} + []);
// Q4: What will be the output?
console.log(0 == false);
console.log(0 === false);
console.log("" == false);
console.log("" === false);
// Q5: What will be the output?
console.log(null == undefined);
console.log(null === undefined);
Day 3: Functions & Execution Context
Core Questions:
- What are the different ways to create functions in JavaScript?
- Follow-up: What's the difference between function declaration and function expression?
- Follow-up: When would you use an arrow function vs regular function?
- Explain the execution context in JavaScript
- Follow-up: What is the call stack?
- Follow-up: What are the phases of execution context creation?