Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda