Are ES6 classes hoisted in JavaScript?
No. Classes are not hoisted (unlike function declarations). You must declare a class before using it. This is intentional: classes use TDZ (temporal dead zone) like let/const.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Constructor Functions vs ES6 Classes in JavaScript
Classes have cleaner syntax, use extends/super for inheritance, throw without new, are not hoisted, and are always strict. Constructor functions require manual prototype chain setup and do not enforce new. Classes are syntactic sugar over the same prototype system.
Yes. class Person { greet() {} } puts greet on Person.prototype. extends sets up the prototype chain (Student.prototype.__proto__ = Person.prototype). Under the hood, it is the same prototypal inheritance.
Yes. Calling a class constructor without new throws TypeError: Class constructor Person cannot be invoked without 'new'. This prevents the forgotten-new bug that constructor functions have.
Still have questions?
Browse all our FAQs or reach out to our support team
