Note: super is a keyword and these super moist banana nut bread recipe special syntactic constructs. Within a class’s body, the reference of super can be either the superclass’s constructor itself, or the constructor’s prototype, depending on whether the execution context is instance creation or class initialization.
See the Examples section for more details. Note that the reference of super is determined by the class or object literal super was declared in, not the object the method is called on. When setting properties through super, the property is set on this instead. Accessing super in class field declarationsuper can also be accessed during class field initialization. The reference of super depends on whether the current field is an instance field or a static field. Note that instance fields are set on the instance instead of the constructor’s prototype, so you can’t use super to access the instance field of a superclass.
Super can also be used in the object initializer notation. In this example, two objects define a method. In the second object, super calls the first object’s method. The same happens in object literals. Only resetting the entire inheritance chain will change the reference of super. This is especially important when interacting with static private properties. Setting properties of super, such as super.
1 will look for the property descriptor of x on A. This means that while methods that get super. 1 still consults the property descriptor of the prototype object, which means you cannot rewrite non-writable properties, and setters will be invoked. Found a content problem with this page? This page was last modified on Dec 13, 2022 by MDN contributors.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation. Content available under a Creative Commons license. Cómo utilizar el método super en Java? Métodos, constructores, clases, palabras reservadas, etc. Java nos tiene acostumbrados a disponer de muchas herramientas útiles a la hora de programar nuestros proyectos. Hoy te contamos de qué va la palabra clave super. El método super nos permite reutilizar bloques de código sin tener que volver a escribir lo mismo, invocando al constructor de una clase superior, desde una clase hija y hacia una clase padre.