Fetching data from SQLite and making it global across navigation pages -- Is this asynchronous problem or global namespace problem?

Question

I've following functions in dbData.js file. I want to use different functions from this file to different pages in my navigation app.

First I want to select an existing user and display her name on home page. I can select name and display on console from the follwong selectUser function, but how can I access it on home.html page? I'm trying to use many different approaches like below.
But nothing works.

I'm trying to call this function in processed method, but all these different approaches gives me "undefined" value. Like in following image. First it prints console.log as undefined and then opens the SQLite and then calls selectUser method.
The problem is the assignment is done first and after that the selectUser() method is called. Why so? What am I doing wrong?

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Thanks for the reply. I did exactly same as said here, but it does not work either. It calls the console.log(loggerUser) first, giving it undefined value. After that it prints print statements from selectUser() function. I tried localStorage, it gives
the same problem as well.

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.