Availability
JavaScript 1.1; JScript 2.0; ECMAScript v1
Inherits from/Overrides
Inherits from Object
Synopsis
arguments
Elements
The
Arguments object is defined only within a function body. Although it
is not technically an array, the Arguments object has numbered
properties that function as array elements and a
length property that specifies the number of array
elements. Its elements are the values that were passed as arguments
to the function. Element 0 is the first argument, element 1 is the
second argument, and so on. All values passed as arguments become
array elements of the Arguments object, whether or not those
arguments are given names in the function declaration.
Properties
callee
A reference to the function that is currently executing.length
The number of arguments passed to the function and the number of
array elements in the Arguments object.
Description
When a function is invoked, an Arguments object is created for it and
the local variable arguments is automatically
initialized to refer to that Arguments object. The main purpose of
the Arguments object is to provide a way to determine how many
arguments were passed to the function and to refer to unnamed
arguments. In addition to the array elements and
length property, however, the
callee property allows an unnamed function to
refer to itself.
For most purposes, the Arguments object can be thought of as an array
with the addition of the callee property. However,
it is not an instance of Array, and the
Arguments.length property does not have any of the
special behaviors of the Array.length property and
cannot be used to change the size of the array.
The Arguments object has one very unusual
feature. When a function has named arguments, the array elements of
the Arguments object are synonyms for the local variables that hold
the function arguments. The Arguments object and the argument names
provide two different ways of referring to the same variable.
Changing the value of an argument with an argument name changes the
value that is retrieved through the Arguments object, and changing
the value of an argument through the Arguments object changes the
value that is retrieved by the argument name.
See Also
Function; Chapter 7
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.