Function length property
Each function has two properties: length and prototype. The length property indicates the number of named arguments that the function expects:
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function sayName(name){
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>
Home
JavaScript Book
Essential Types
JavaScript Book
Essential Types
Function:
- The Function Type
- Function Declarations versus Function Expressions
- Functions as Values
- Returning a function from a function
- Function arguments
- this for function context
- Function caller
- Function length property
- Function apply()
- Function.call() method
- Function's bind() method
- Function toLocaleString() and toString()