Function arguments
The arguments object is an array-like object that contains all of the arguments. The arguments object has a callee property pointing the function.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function factorial(num){
if (num <= 1) {
return 1;
} else {
return num * factorial(num-1)
}
}
document.writeln(factorial(5)); //120
function factorial(num){
if (num <= 1) {
return 1;
} else {
return num * arguments.callee(num-1)
}
}
document.writeln(factorial(5)); //120
</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()