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

102
Vistas
Does javascript singleton require double parentheses?
  • I created a Singleton-like function for a Google Sheet of mine;
  • Priv and Pub is my way of simulating Private and Public;
  • When I assign its instance to a variable, I need to type ()() so it works the way I want it to. I want to be able to type Priv.whateverProp
  • I've tried double parentheses in other places inside the Singleton function, but when I accomplish getting to use only one (), then the completions display apply, bind, call etc.
  • Then I have to getInstance()().completions** again to access the instance properties, but when I run the program, it says SingletonFinder().getInstance() is not a function
  • So I have to leave getInstance() with its single parentheses and type Priv().whaterverProp instead of Priv.whateverProp for the rest of the code, which I don't want.
  • Why do I have to type it this way let Priv = SingletonFinder().getInstance()() ?
function GetFinder(){
    let Pub = {}
    let Priv = SingletonFinder().getInstance()()
    // the rest of the code...
}

function SingletonFinder() {
    let Priv = {}
    let Pub = {}

    /** @type {Class_Finder} */
    Priv.instance = null;
    Priv.createInstance = function () {
        return Class_Finder
    }
    Pub.getInstance = function () {
        if(!Priv.instance) {
            Priv.instance = Priv.createInstance()
        }
        return Priv.instance
    };
    return Pub
}

function Class_Finder() {
    // properties
}
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