JavaScript Internals (521 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
What is the difference between function and class declarations
The main difference between function declarations and class declarations is hoisting. The function declarations are hoisted but not class declarations.
Classes:
javascript
const user = new User(); // ReferenceError
class User {}
Constructor Function:
javascript
const user = new User(); // No error
function User() {}