|
If will fire when the return from the last recursive call is made. Whether or not it fires subsequently will depend upon whether or not any subsequent calls are made. Here's your sequence: You begin with imageNum = 1, image "xx". Because of that, you increment imageNum and make a recursive call. The image will not be "xx", so you don't make another call, but return from the first recursive call. At that point you will get a "yy" alert, then return from the original call. The imgNumber will be 4 and mainPic.src will be 28.jpg.
I might suggest that there is little use for recursion here. Possibly you're just playing around. If so, avail yourself of more alerts in more paths, with more information.
|