Use length property from function in JavaScript
Description
The following code shows how to use length property from function.
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function sayName(name){<!--from w w w . j a v a 2s.com-->
document.writeln(name);
}
function sum(num1, num2){
return num1 + num2;
}
function sayHi(){
}
document.writeln("hi");
document.writeln(sayName.length); //1
document.writeln(sum.length); //2
document.writeln(sayHi.length); //0
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Parameter
Access Arguments object of the calling func...
Access Function Arguments with the argument...
Access caller from arguments in JavaScript
Access function that is currently executing...
Access the number of arguments that were pa...
Change the value of an object in a function...
Get function parameter length in JavaScript
Pass Form value to a function in JavaScript
Pass an array to a function in JavaScript
Pass number to a function in JavaScript
Pass string value to a function in JavaScri...
Use arguments array to access parameters pa...
Use arguments.callee.toString() to get the ...
Use arguments object to work with parameter...
Use functionName.arguments to access functi...
Use functionName.arguments to reference the...
Access Arguments object of the calling func...
Access Function Arguments with the argument...
Access caller from arguments in JavaScript
Access function that is currently executing...
Access the number of arguments that were pa...
Change the value of an object in a function...
Get function parameter length in JavaScript
Pass Form value to a function in JavaScript
Pass an array to a function in JavaScript
Pass number to a function in JavaScript
Pass string value to a function in JavaScri...
Use arguments array to access parameters pa...
Use arguments.callee.toString() to get the ...
Use arguments object to work with parameter...
Use functionName.arguments to access functi...
Use functionName.arguments to reference the...