|
Q1170 How can I tell how many arguments have been passed to a function, and what data type the arguments are?
irt.org | Knowledge Base | JavaScript | Function | Q1170 [ previous next ]
Q1170 How can I tell how many arguments have been passed to a function, and what data type the arguments are?
Try:
<script language="JavaScript"><!--
function myFunctionName() {
var o = '';
o += 'Number of arguments = ' + arguments.length + '\n';
for (var i=0;i < arguments.length; i++)
o += 'Argument ' + i + ' typeof = ' + typeof arguments[i] + '\n';
alert(o);
}
myFunctionName(123,'xyz',new Object());
//--></script>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.