Applying object in JavaScript (3)

Source: Internet
Author: User
Eight. Integrated Application
The last example demonstrates the importance of JavaScript objects. Set up a Calendar object first, and then show any one month calendar as needed. The execution process is not complicated, just specify the month and year as the object property, and then let the constructor do something else:
<script language= "JavaScript" >
/* Calendar object, Calendar.js
Usage:
obj = new Calendar (mm, yyyy);
Created 15.mar.2001
Copyright Melonfire, 2001. All rights reserved.
http://www.melonfire.com/community/columns/trog/
Demonstration Only-not meant for production enviroments!!
*/
Constructor
function Calendar (month, year)
{
Array of day names
This.days = new Array ("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday");
Array of month names
This.months = new Array ("January", "February", "March", "April", "may",
"June", "July", "August", "September", "October", "November", "December");
Array of Total month
This.totaldays = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
Object Properties-month and year
Correction for zero-based array index
This.month = month-1;
This.year = year;
Leap Year correction
if (this.year% 4 = 0)
{
THIS.TOTALDAYS[1] = 29;
}
Temporary variable-used later
This.rowcount = 0;
Object method
This.display = display;
Automatically run method display () Once the object is initialized
This.display ();
}
function to display calendar
function display ()
{
Create a Date object
Required to obtain basic date information
Get the "the" and "the" Month-boundary Values for calendar
obj = new Date (This.year, This.month, 1);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.