| home / programming / java_core / 1 | [previous] [next] |
|
|
The Date object has a prototype property that allows you to extend the capabilities of the object. You can customize the time and the date by providing new methods and properties that will be inherited by all instances of this object. Since the Date object provides methods that return zero-based months, weeks, years, and other measures you may want to create a prototype method where "January" is month number 1 instead of 0, and the day is "Monday" instead of 1, etc.
|
|
|---|
|
<html><head><title>The Prototype Property</title> <script language = "javascript"> 5 Date.prototype.DayOfWeek=weekDay; <script language="JavaScript"> 7 document.write("Today is " + today.DayOfWeek() + ".<br>"); |
|
|
|---|
The function called weekday() is defined. |
|
| home / programming / java_core / 1 | [previous] [next] |
| ||||||||||||||||||||
Created: March 27, 2003
Revised: November 19, 2003
URL: http://webreference.com/programming/java_core/1