Get to know MDN better
The JavaScript exception "derived class constructor returned invalid value x" occurs when a derived class constructor returns a value that is not an object or undefined.
Typically, a constructor does not need to return anything—the value of this is automatically returned when the class is constructed. A constructor can also return an object, and this object will override this as the newly constructed instance. However, returning something that's neither an object nor undefined is usually a mistake, because that value is ignored. In base classes and function constructors (using the function syntax), returning such a value is silently ignored, while in derived classes, it throws an error.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.