Home  >  Article  >  Web Front-end  >  js中函数function length属性详解

js中函数function length属性详解

WBOY
WBOYOriginal
2016-06-01 09:55:022103browse

相信大家对js中的字符串和数组的length都比较了解,但是js中函数function也有length属性,该属性表示定义函数的参数个数,与arguments不同,arguments表示实际接受的参数。
看下面实例:

<code><script type="text/javascript">
function sumfun(sum1,sum2,sum3,sum4) {
    return sum1+sum2+sum3+sum4;
}
alert(sumfun.length); //运行结果:4
</script></code>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn