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()