The main difference between function declarations and class declarations is hoisting. The function declarations are hoisted but not class declarations.
Classes:
1 2 3 | const user = new User(); // ReferenceError class User {} |
Constructor Function:
1 2 3 4 | const user = new User(); // No error function User() { } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.