Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.