Use functionName.arguments to access function parameters in JavaScript

Description

The following code shows how to use functionName.arguments to access function parameters.

Example


<!-- w w  w. j ava2s . com-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

function foo(a,b) {
foobar(123);
document.write("Done with function foo" + "<br>");
}
function foobar(x) {
document.write(foobar.arguments.length + "<br>");
document.write(foobar.arguments.caller.b + "<br>");
}
document.write(foo(21,44) + "\n");
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use functionName.arguments to access function parameters in JavaScript