arguments.length

JavaScript 1.1+, ECMAScript 1.0+ Nav3+ Syntax

arguments.length

Description

The length property of the Arguments object contains the number of arguments that were passed into the function to which the Argument object is associated. If less arguments are passed in than are specified in the definition of the function, the length property will only contain the number of arguments passed into the function. This number matches the number of elements in the arguments array associated with the Argument object.

Example

In Listing 6.46, the length property of the Argument object is used to process any number of arguments passed into the displayFood() function.

Listing 6.46 Using the length Property to Access Elements of the ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.