How does the new main function access the values of icon and i? How are those values passed from the moment created in the event listener to the scene level object’s main function? FYI this is an example of “closure.” Closure is the passing of variable values from an “outer” function to an “inner” function.
The main function is what accesses the values of both icon and i. It does this through the runScene function.
- eventListener is used to store the icon and i
- the values of both i and icon are passed to runScene from the eventListener
- the runScene passes the values back to the main function we created.