Workiz interview question

How js will prioritize functions asynchronously. How does an index work on a database