About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Tutorial archive
General Questions
Javascript 1.2
Navigation
Numbers
Strings
Object Model
Reference Manual
Dialog
Windows
Frames
Forms
Images
Mouse Events
Colors
File Access
Control Status Bar
Dates and Time
Cookies
Client Information
Bookmarklets







[Contents] [Previous] [Next] [Last]


Chapter 3

Functions

This section describes the following new functions and features of functions:

Nesting Functions Within 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.

Number

Core function. Converts the specified object to a number.

Syntax

Number(x)

Parameter

x is any object.

Description

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.

Example

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."

String

Core function. Converts the specified object to a string.

Syntax

String(x)

Parameter

x is any object.

Description

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.

Example

The following example converts the Date object to a readable string.

<SCRIPT LANGUAGE="JavaScript1.2">
D = new Date (430054663215); 
document.write (String(D) +" <BR>");
</SCRIPT>

This prints "Thu Aug 18 04:37:43 Pacific Daylight Time 1983."


[Contents] [Previous] [Next] [Last]