|
July 13, 2000 JavaScript Calendar Tips: July 2000
Yehuda Shiran, Ph.D.
|
|
When you implement a function, always try to minimize the number of if statements. It helps the performance, of course, but more importantly it makes the function much more simpler to maintain. Take for example the following function that accepts the month of the year and the year, and returns the number of days in that month. The year is needed just for leap-year adjustment:
The function stores in an array the count of days in each month, and then returns the proper element of the array. This function is part of our Calendar application. To see further how we wrote it, go to Column 64, HTML Components.
People who read this tip also read these tips: Look for similar tips by subject: |