Function Object
CSGNetwork FREE Source Code, Javascript Source, and Code Snippets!
CSGNetwork Custom Search
     Bookmark and Share
 
CSGNetwork
Snippets
Calculators
Top Free Apps
Home
Back



Right click this window and select "view source" in order to copy the source for this script.

Function Object

There are several ways to define a function in JavaScript:

Function Statement:

function functionname(arguments){ //standard function
statements...
}

function (arguments){ //unnamed function. JavaScript 1.2.
statements...
}

Constructor:

new Function(arguments, body)

Properties

Properties Description
Arguments A local variable that points to the Arguments object, which in turn contains all of the arguments passed into the function. Use "arguments.length" to determine the number of arguments entered. Note that this is different from the old arguments[] array, which has been deprecated in JavaScript 1.2. Example(s)
caller References the invoking function, if any.
length Returns the number of named arguments specified.
prototype Prototype property, to add custom properties and methods to this object.

Methods

Methods Description
apply() n/a
call() n/a
toString() n/a

Examples

Arguments(x)

This function below alerts the number of arguments passed into it:

function tellme(){
alert(arguments.length)
}

tellme(1,2,3) //alerts 3
tellme("George", "Tom") //alerts 2



Bookmark and Share
Registered® Trademark™ and Copyright© 1973 - CSG, Computer Support Group, Inc. and CSGNetwork.Com All Rights Reserved