Rootstack Interview Question

How does the promises work on JavaScript?