\chapter Built-in Variables and Constants

\Q provides a number of convenient built-in constants and variables.

The built-in variables include \l arguments.

The built-in constants include \l Infinity, \l NaN and \l undefined.

\section1 Built-in Variables

\section2 arguments

This is an \l Array of the arguments that were passed to the function.
It only exists within the context of a function.

Example:
\code
    function sum()
    {
	total = 0;
	for ( i = 0; i < arguments.length; i++ ) {
	    total += arguments[ i ];
	}
	return total;
    }
\endcode

\section1 Built-in Constants


\section2 Infinity

This is the value of any division by zero, i.e.
\code
    var i = 1/0;
\endcode
In \QS, division by zero does not raise an exception; instead it
assigns the \c Infinity value as the result of the expression. Use \l
isFinite() to test whether a value is finite or not.

\section2 NaN

Some functions that are supposed to return a numeric result may return
\c NaN instead. Use \l isNaN() to check for this.

\section2 undefined

This is the value of a variable that does not have a defined value,
i.e. has not been assigned to.

Example:
\code
    var i;
    // ...
    if ( i == undefined ) {
	i = 77;
    }
\endcode
In this example, if execution reaches the \c if statement, and \c i
has not been assigned a value, it will be assigned the value 77.
