Hint
Classes behave like let/const: hoisted to TDZ, not callable before their declaration. Unlike function declarations which are fully hoisted.
try {
const obj = new MyClass();
} catch(e) {
console.log(e.constructor.name);
}
class MyClass {
constructor() { this.x = 1; }
}
const obj2 = new MyClass();
console.log(obj2.x);ReferenceError 1
Explanation: class declarations are hoisted but stay in the TDZ — accessing them before declaration throws ReferenceError. After the declaration, they work fine.
Key Insight: Classes behave like let/const: hoisted to TDZ, not callable before their declaration. Unlike function declarations which are fully hoisted.