JavaScript & V8 Internals (536 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
What is the difference between function and class declarations
senior LevelCode ExampleMemory Management
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() {}