O'Reilly logo

The Book of JavaScript, 2nd Edition by thau!

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required