User Tools

Site Tools


Function

ECMASCript Function prototype object.

More...

Inherits :

Properties

Constructors

ECMAScript
Function ( String p1, String p2, …, String pn, String body )

Methods

ECMAScript
Objectapply ( Object thisArg, Array argArray )
voidbind ( Object thisArg, … )
Objectcall ( Object thisArg, … )
StringtoString ()
QtScript
voidconnect ( Object receiver, String function )
voidconnect ( Function functionRef )
voiddisconnect ( Object receiver, String function )
voiddisconnect ( Function functionRef )
DAZ Script
voidscriptConnect ( Object receiver, String function )
voidscriptConnect ( Function functionRef )
voidscriptDisconnect ( Object receiver, String function )
voidscriptDisconnect ( Function functionRef )

Detailed Description

Examples:

function myFunction()
{
	//do something...
}
var myFunction = function()
{
	//do something...
}

See Also:

Properties


Array : arguments

An “array-like” object (has a length property and zero-indexed properties like an Array, but none of the other properties/methods of an actual Array) containing values for each argument the function was called with.

Example:

function sum(){
	var nTotal = 0;
	for( var i = 0; i < arguments.length; i += 1 ){
		nTotal += arguments[ i ];
	}
 
	return nTotal;
}
print( sum( 2, 3, 4, 5 ) ); //14

Number : length

Holds the number of arguments expected by the function.

Constructors


Function( String p1, String p2, …, String pn, String body )

Default Constructor. Creates a new function. All arguments are optional - zero or more argument names may be specified, the last argument, if any, is always used as the body of the function.

Parameter(s):

  • p1 - The name of the first parameter.
  • p2 - The name of the second parameter.
  • pn - The name of the last parameter.
  • body - The text of the executable code of the function.

Methods


Object : apply( Object thisArg, Array argArray )

Performs a function call with a given this value and argArray arguments.

Attention:

  • The syntax of this function is almost identical to that of call(). A fundamental difference, however, is that call() accepts optional arguments to the Function itself, while this function accepts an array of arguments.

Parameter(s):

  • thisArg - The object that serves as the this value for the function call. If undefined, or not provided, the global object is used.
  • argArray - An optional array of arguments for the function; if not provided, the function is called without any arguments.

Return Value:

  • The return value of the function.

void : bind( Object thisArg, … )

Creates a new function that, when called, has its this keyword set to thisArg, with the given sequence of arguments preceding any provided when the new function is called.

Parameter(s):

  • thisArg - The object that serves as the this value for the function call. If undefined, or not provided, the global object is used.
  • - Optional argument(s) to prepend to arguments provided to the bound function when invoking the function being bound.

Object : call( Object thisArg, … )

Performs a function call with a given this value and optional arguments.

Attention:

  • The syntax of this function is almost identical to that of apply(). A fundamental difference, however, is that apply() accepts an array of arguments, while this function accepts optional arguments to the function itself.

Parameter(s):

  • thisArg - The Object that serves as the this value for the function call. If undefined, or not provided, the global object is used.
  • - Optional argument(s) for the function.

Return Value:

  • The return value of the function.

String : toString()

Return Value:

  • A string representation of the function.

void : connect( Object receiver, String function )

Deprecated

Exists only to keep old code working. Do not use in new code. Use scriptConnect() instead.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.
  • Any connections established using this method will persist until one of the following conditions is met:
    • A discrete call to disconnect() with the same parameter values is made
    • The object that provides the signal is destroyed
    • receiver is destroyed
    • The script engine is reset
    • The application closes

void : connect( Function functionRef )

Deprecated

Exists only to keep old code working. Do not use in new code. Use scriptConnect() instead.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.
  • Any connections established using this method will persist until one of the following conditions is met:
    • A discrete call to disconnect() with the same parameter values is made
    • The object that provides the signal is destroyed
    • functionRef is destroyed
    • The script engine is reset
    • The application closes

void : disconnect( Object receiver, String function )

Deprecated

Exists only to keep old code working. Do not use in new code. Use scriptDisconnect() instead.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.

void : disconnect( Function functionRef )

Deprecated

Exists only to keep old code working. Do not use in new code. Use scriptDisconnect() instead.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.

void : scriptConnect( Object receiver, String function )

Connects a signal to a function (slot) on another object.

Parameter(s):

  • receiver - The object that will receive the signal.
  • function - The function on receiver to execute when this signal is emitted.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.
  • Any connections established using this method will persist until one of the following conditions is met:
    • A discrete call to scriptDisconnect() with the same parameter values is made
    • The object that provides the signal is destroyed
    • receiver is destroyed
    • The script falls out of scope (ends)

See Also:

Since:

  • 4.14.1.31

void : scriptConnect( Function functionRef )

Connects a signal to a function

Parameter(s):

  • functionRef - The function to execute when this signal is emitted.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.
  • Any connections established using this method will persist until one of the following conditions is met:
    • A discrete call to scriptDisconnect() with the same parameter values is made
    • The object that provides the signal is destroyed
    • functionRef (or the object that provides it) is destroyed
    • The script falls out of scope (ends)

See Also:

Since:

  • 4.14.1.31

void : scriptDisconnect( Object receiver, String function )

Disconnects a signal from a function (slot) on another object.

Parameter(s):

  • receiver - The object that receives the signal.
  • slot - The method on receiver to disconnect.

Attention:

  • This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.

See Also:

Since:

  • 4.14.1.31

void : scriptDisconnect( Function functionRef )

Disconnects a signal from a function

Parameter(s):

  • functionRef - The function to disconnect from.

Attention:

  • * This method can only be called on a Function that is a signal - calls to this method on a Function that is not a signal will result in a TypeError.

See Also:

Since:

  • 4.14.1.31