Get to know MDN better
The JavaScript exception "use of super property/member accesses only valid within methods or eval code within methods" occurs when the super.x or super[x] syntax is used outside of a method.
The super.x syntax is used to access properties on the prototype of the current object. It can be used in methods of both object literals and classes, field initializers, and static initialization blocks, but not in other contexts.
You can't use super.x outside of a method in an object:
You can't use super.x in a function, even if that function has the effect of being a method:
You can use super.x in a method:
You can use super.x in a field initializer:
You can use super.x in object methods too:
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.