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

176
Vistas
What are the benefit of assigning function results to variables vs calling inline?

I'm learning Firebase. In many code examples I see something like this:

const auth = getAuth();

await signInWithPopup(auth, provider);

while in firebase web codelab they call getAuth directly:

await signInWithPopup(getAuth(), provider);

same thing with getFirestore.
so which one is the correct way of doing it and if they are both the same what is the better practice?

edit: when I need to use auth object more than once will I get any performance benefits by calling getAuth once and assigning it to a variable?

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

0

These two code examples are functionally the same. The first example is simply more verbose.

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you don't need to reuse the auth variable, then you can simply call it directly.

It doesn't have any significant difference in this case.

about 4 years ago · Juan Pablo Isaza Denunciar

0

There's no difference between those two approaches. If you want to use the result that is returned by getAuth(), only once, it makes sense to use it like this:

await signInWithPopup(getAuth(), provider);

Otherwise, save it to the auth variable and use it as many times as you want. In terms of performance, there is no difference at all.

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