JavaScript之arguments
来源:互联网 发布:什么是访客网络设置 编辑:程序博客网 时间:2024/06/07 14:51
arguments
arguments[n]
arguments是个类似数组但不是数组的对象,能够由arguments[n]来访问对应的单个参数的值,并拥有数组长度属性length。arguments对象存储的是实际传递给函数的参数,而不局限于函数声明所定义的参数列表。用Array.prototype.slice.call()可将arguements对象转变为数组
function add(n){ var res=[].slice.call(arguments); console.log(arguments.length); console.log(res);}add(5);//1//[5]
callee
arguments.callee
返回当前函数。表示对函数对象本身的引用,这有利于匿名函数的递归或确保函数的封装性。
function My(){ console.log(arguments.callee);}My();//function My(){// console.log(arguments.callee);//}function add(n){ if(n<1) return 0; return n+arguments.callee(n-1);}console.log(add(5));//15function add(n){ console.log(arguments.length);//实际传给函数的参数列表长度 console.log(arguments.callee.length);//函数声明所定义的参数列表长度}add();//0//1
caller
FunctionName.caller
返回调用当前函数的函数。若函数是在顶层调用的,返回null。
function My(){ console.log(My.caller.toString()); //也可用console.log(arguments.callee.caller.toString());}function Your(){ My();}Your();//function Your(){// My();//}function My2(){ console.log(arguments.callee.caller);}My2();//null
1 0
- javascript之arguments详解
- javascript之arguments对象
- Javascript之arguments
- JavaScript之arguments
- javascript函数之arguments(2)
- 深入理解javascript之arguments
- javascript内置对象之arguments
- JavaScript之学习arguments对象
- javascript函数之arguments学习
- JavaScript 之arguments、caller 和 callee 介绍
- JavaScript 之arguments、caller 和 callee
- JavaScript 之arguments、caller 和 callee 介绍
- JavaScript 之arguments、caller 和 callee 介绍
- JavaScript 之arguments、caller 和 callee 介绍
- JavaScript 之arguments、caller 和 callee 介绍
- JavaScript基础(2)之arguments详解
- JavaScript-函数传参之arguments
- javascript ( arguments )
- Linux 日期和时间操作详解
- JavaScript中变量和函数的提升学习
- 项目体会 合格的Leader 应该具备什么特质?
- [LPE]Windows Local Privilege Escalation MS15-051
- J. Panoramic Photography----思维题
- JavaScript之arguments
- OJ-------从单向链表中删除指定节点
- 机器学习课程 笔记
- Ubuntu12.10编译MPTCP
- Python 日志组件学习(一)
- React Native 配置环境(iOS and Android)
- RecyclerView实现复杂布局
- 美国大学最新排名较以往变化不大 名校对语言成绩(雅思)要求更高
- scala编程实战 scala编程实战pdf 下载