O'Reilly logo

Web Design Blueprints by Benjamin LaGrone

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

Object and function conventions

In your header file, there is a script tag with the clock script in it. Use that for now, and eventually this will grow into a few different scripts as it becomes bigger. Let's get it started in an organized way; there's no sense in creating a debt of disorganization to clean up later.

In the beginning of the script, add a variable object named home:

var home = {};
Then, prepend all variables and functions following this with home instead of leaving them as newly defined. This adds them to that home object. This will prevent confusion and collisions later on. This looks like the following: var home = {}; home.dayArray = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; home.monthArray = ["January","February","March","April","May","June","July","August","September","October","November","December"]; ...

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