[Contents]
This section describes the following new functions and features of functions:
You can nest a function within a function. The nested function can use the arguments and variables of the outer function. The outer function cannot use the arguments and variables of the nested function.
Core function. Converts the specified object to a number.
Number(x)
x
When the object is a Date object, Number returns a value in milliseconds measured from 01 January, 1970 UTC (GMT), positive after this date, negative before.
Date
Number
The following example converts the Date object to a numerical value:
<SCRIPT LANGUAGE="JavaScript1.2">
d = new Date ("December 17, 1995 03:24:00"); document.write (Number(d) + "<BR>");
</SCRIPT>
This prints "819199440000."
Core function. Converts the specified object to a string.
String(x)
When the object is a Date object, String returns a string representation of the date. Its format is: Thu Aug 18 04:37:43 Pacific Daylight Time 1983.
String
The following example converts the Date object to a readable string.
D = new Date (430054663215); document.write (String(D) +" <BR>");
This prints "Thu Aug 18 04:37:43 Pacific Daylight Time 1983."