Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
How can I call same-level method in base class?

This is the code I have

class Parent {
  async A(part, id) {
  }

  async B(part, id) {
    await this.A(part, id)
  }
}

class Child extends Parent {
  async A(id) {
  }

  async B(id) {
    await super.B("part1", id);
    // ...
  }
}

// let's assume I'm in async context
const child = new Child();
await child.B();

So what is happening here is the Child.B is calling Parent.B, and Parent.B is calling Child.A (which is expected).

I want to know if there is a way for me to call Parent.B > Parent.A.

I realize that perhaps I need to rename the methods, but I wanted to know if there is a way for this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to call a method of a specific class instead of looking it up on the instance (on this) or your own prototype (trough super), reference that method directly and .call it on the instance:

class Parent {
  async A(part, id) {
  }

  async B(part, id) {
    await Parent.prototype.A.call(this, part, id)
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda