I have a question regarding JavaScript functions.
As an example, please refer to the below code.
- In the first 2 lines, I open an indexedDB.
- After that, I attach the onsuccess function to the openRequest.
- The alert comes up correctly.
I am assuming that the 'open' function triggers the 'success' event function. But how can this work, since the 'success' function is attached to the openRequest after the 'open' function is called?
var indexedDB = window.indexedDB;
var openRequest = indexedDB.open('MyTestDB');
openRequest.onsuccess = function (response) {
alert('sucess');
};