函数
来源:互联网 发布:青岛淘宝美工培训 编辑:程序博客网 时间:2024/06/05 19:02
arguments:参数的集合
fn1(1,2,3);//实参function fn1(a,b,c){//形参 // arguments ==> [1,2,3]实参的集合 //alert(arguments);//object Arguments alert(arguments.length);//3 alert(arguments[0]);//1 alert(arguments[arguments.length-1]);//找最后一个实参}
什么时候使用arguments?
当函数的参数个数无法确定的时候。
function sum(){ var n = 0; for(var i=0;i<arguments.length;i++){//arguments.length是实参的长度 n += arguments[i];//让实参相加 } return n;}alert(sum(1,2,3));//6 alert(sum(1,2,3,4));//10
阅读全文
0 0
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- MyEclispe工作空间配置(Eclispe大部分通用)
- 懒惰、急躁、傲慢
- 使用jQuery插件
- 216. Combination Sum III
- vue 自定义指令 focus 条件聚焦 时,在与v-if共存时需要处理的问题
- 函数
- Shell学习之传递参数
- Eclipse常用设置
- 对象和xml相互转换工具XMLEncoder,XMLDecoder
- Android第三方库隔离之对第三方图片加载库的隔离
- api-ms-win-crt-runtimel1-1-0.dll缺失
- 多线程的创建与运行
- xcode archive 去掉dsym文件和添加dsym文件
- SpringBoot-SpringData-懒加载