FrontendDeveloper.in

JavaScript question detail

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:

const user = new User(); // ReferenceError

class User {}

Constructor Function:

const user = new User(); // No error

function User() {}
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399