Function.arity

JavaScript 1.2 Nav4+, NES3+ Syntax

							function.arity

Description

The arity property of the Function object represents the number of declared arguments a function expects to receive. This is valid when the language attribute of the script tag is set to JavaScript1.2.

Example

Listing 6.127 shows how arity can be used. The first line written to the user's page contains the number of arguments passed to the function. The second line is the result of running the script.

Listing 6.127 Example of Using arity
 <html> <body> <script lanuguage="JavaScript1.2"> <!–– Hide // function subtracts the second number from the first function subtract(first, second){ var result = first – second; return result; } // Write the results to 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.