let, var, and const
- Key Concepts to Cover:
- Differences between
let, var, and const.
- Block-scoping with
let and const.
- Reassignability with
let and immutability with const.
- Hoisting behavior of
var vs. let and const.
- Practice Questions:
- What is the difference between
let, var, and const in JavaScript?
- Write code examples where the difference in scoping of
let and var affects the output.
- Explain how
const works with objects and arrays.
- Task:
- Write a program where the variables are declared using all three (
let, var, const) and explain the output when used inside and outside a function block.
Data Types
- Key Concepts to Cover:
- Primitive vs. non-primitive data types.
- Numbers, Strings, Booleans,
null, undefined, Symbols.
- Reference types: Objects, Arrays, and Functions.
- Type coercion and type conversion.
- Practice Questions:
- What are primitive and non-primitive data types in JavaScript?
- Explain how type coercion works in JavaScript with examples.
- Write a program to check whether a variable is primitive or non-primitive.
- Task:
- Write a program demonstrating type coercion in a comparison (e.g., using
== and ===).
Scope
- Key Concepts to Cover:
- Function scope, Block scope, and Global scope.
- Lexical scoping and the
this keyword.
- Practice Questions:
- What is the difference between function scope and block scope?
- How does lexical scoping work in JavaScript? Provide an example.
- How is
this determined in different scopes?
- Task:
- Write a program demonstrating the difference between function scope and block scope using functions and
let, var.
Hoisting
- Key Concepts to Cover:
- How hoisting works with
var, let, const, and functions.
- Temporal Dead Zone (TDZ) related to
let and const.
- Practice Questions:
- Explain how variable and function hoisting works in JavaScript.
- What is the Temporal Dead Zone (TDZ)? How does it relate to hoisting?
- Write a program that shows how hoisting affects variables declared with
var vs let.
- Task:
- Create a function and demonstrate hoisting of variables and functions within it. Explain the output.
Temporal Dead Zone (TDZ)
- Key Concepts to Cover:
- TDZ for
let and const.
- The relationship between hoisting and TDZ.
- Practice Questions:
- What is the Temporal Dead Zone, and how does it affect the execution of
let and const?
- Explain why accessing a
let or const variable before declaration throws an error.