function.lengthプロパティは、Functionオブジェクトの仮引数の数を返すプロパティ。
構文
function.length
サンプル
<script type="text/javascript">
var $funcA = new Function( "arg1", "arg2", "return arg1 + arg2" );
document.write( '$funcA.length: ' + $funcA.length + '<br />' );
var $funcB = new Function( "arg1", "arg2", "arg3", "arg4", "arg5", "return arg1 + arg2" );
document.write( '$funcB.length: ' + $funcB.length + '<br />' );
function funcC( arg1, arg2 ) {
return arg1 + arg2;
}
document.write( 'funcC.length: ' + funcC.length + '<br />' );
function funcD( arg1, arg2, arg3, arg4, arg5 ) {
return arg1 + arg2;
}
document.write( 'funcD.length: ' + funcD.length + '<br />' );
</script>
var $funcA = new Function( "arg1", "arg2", "return arg1 + arg2" );
document.write( '$funcA.length: ' + $funcA.length + '<br />' );
var $funcB = new Function( "arg1", "arg2", "arg3", "arg4", "arg5", "return arg1 + arg2" );
document.write( '$funcB.length: ' + $funcB.length + '<br />' );
function funcC( arg1, arg2 ) {
return arg1 + arg2;
}
document.write( 'funcC.length: ' + funcC.length + '<br />' );
function funcD( arg1, arg2, arg3, arg4, arg5 ) {
return arg1 + arg2;
}
document.write( 'funcD.length: ' + funcD.length + '<br />' );
</script>
↓↓↓出力結果↓↓↓