Do ES6 classes require new in JavaScript?
Yes. Calling a class constructor without new throws TypeError: Class constructor X cannot be invoked without 'new'. This prevents the forgotten-new bug that function constructors have.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in this in Constructors and the new Keyword in JavaScript
It creates a new empty object, sets this to that object inside the function, runs the function body, and returns this (the new object) unless the function returns its own object.
this becomes the global object (or undefined in strict mode). Properties get added to window instead of a new object. The function returns undefined. This is a common bug with function constructors.
Yes. If you call a bound function with new, this is a new object, not the bound this. However, any preset arguments from bind still apply to the new object.
Still have questions?
Browse all our FAQs or reach out to our support team
