Forum Moderators: open
You could, however, pass variables, determine their nature and branch your code.
Yes, the arguments passed to a function are stored in an array called arguments. Length is the property that exposes the number of elements in an array, as in:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function myFunc(a,b,c,d){
document.write('<p>Length of array: '+ myFunc.arguments.length +'<br \/>');
document.write('First array entry: '+ myFunc.arguments[0] +'<br \/><\/p>');
document.write('<p><h2>Array Contents:<\/h2>');
var ar_ln=myFunc.arguments.length;
for(var i=0;i<ar_ln;i++){
document.write(myFunc.arguments[i]+'<br \/>');
}
document.write('<\/p>');
document.close();
}
</script>
</head>
<body onload="myFunc(1,2,3);">
</body>
</html>