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

194
Visualizações
Why is it ok to instantiate a class without the 'new' keyword in React?

I am studying Firebase's Google authentication in React. And while following the instruction, I realize that you can instantiate a class from firebase with and without the 'new' key word. I thought in OOP, we have to use the 'new' keyword to instantiate a class and without the 'new' keyword, it's just like calling a function in JS. Can someone please explain why we can instantiate a class like calling a js function here? And what are the differences between those two?

import {initializeApp} from 'firebase/app';
import {getAuth, signInWithRedirect, signInWithPopup, GoogleAuthProvider} from 'firebase/auth'
import {getFirestore, doc, getDoc, setDoc} from 'firebase/firestore'


const firebaseConfig = {
    apiKey: "AIzaSyDwATEHxMW00am02mknls6oWdQLXmWPeuc",
    authDomain: "reactjs-ver1.firebaseapp.com",
    projectId: "reactjs-ver1",
    storageBucket: "reactjs-ver1.appspot.com",
    messagingSenderId: "631316016514",
    appId: "1:631316016514:web:776f3090371772df33339b"
  };



const firebaseApp = initializeApp(firebaseConfig);



const provider = new GoogleAuthProvider(); 
provider.setCustomParameters({
    prompt: "select_account"
})


export const auth = getAuth();   multiple instances of provider
export const signInWithGooglePopup = () => signInWithPopup(auth, provider);
export const db = getFirestore()
about 4 years ago · Juan Pablo Isaza
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