How Space.com's Countdown Script Works

Space.com's countdown script (Figure 9-10) is a bit more complicated than the one on the Book of JavaScript website. However, aside from the calculations involved in determining the time until the next launch, it functions very similarly.

Space.com's countdown script

Figure 9-10. Space.com's countdown script

Line ❶ sets the date of the next space launch (as of the date I accessed this code; you'd see a different date if you selected ViewSource to look at the code now). Up until now, we've seen how to get the current date. Line ❶ shows you how to set the Date object to a specific date. The number after 2005 is the time of the launch, where ...

Get The Book of JavaScript, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.