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

186
Vistas
A function declared inside of a function that is in a class cannot access private variables/functions. Is there a way around this?

class a
{
  constructor(val)
  {
    this.val = val;
  }

  #privFunction()
  {
    console.log(this.val);
  }

  publicFunction()
  {
    var fun = function()
    {
      this.#privFunction();
    };
    fun();
  }
}

const class1 = new a("Hello world!");
class1.publicFunction();

This will return an error that the this.#privFunction() function is not declared in this scope. If I need to find a way to declare a private function in a function that's declared inside of a class' public function is this possible?

about 4 years ago · Juan Pablo Isaza
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