+ 2
You cannot connect JS on the client side directly to database, but you can connect it to cloud providers like AWS and FireBase
You can also connect native JS api to web api which is connected to a database using xhr or fetch api, although xhr is old but some still use it.
JS on the server side as NodeJS can connect directly to database.
I hope this helps...