You'll probably be wondering by now what it is that I'm calling a Promise? Well, a Promise, as it sounds, is a Promise made by JavaScript that the asynchronous function will complete execution at some point.
In the previous chapter, we came across an asynchronous event: reading the contents of a file using FileReader. This is how FileReader worked:
- It starts reading the file. Since reading is an asynchronous event, other JavaScript code will continue execution while reading is still happening.
You might be wondering, what if I need to execute some code only after the event is complete? This is how FileReader handles it:
- Once the reading is complete, FileReader fires a load event
- It also has an onload() method that listens ...