Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!