【js】js中的隐藏对象arguments,caller,callee
来源:互联网 发布:java 自定义文件格式 编辑:程序博客网 时间:2024/05/16 15:50
1.arguments: an array-like object(像数组的对象,可以使用数组的length方法,不可以使用push,pop方法)
·arguments叫做函数内部的期望参数,而调用该函数传入的参数叫做实际传递参数
·栗子:
alert(add(3)); //false function add(x,y){ alert(arguments instanceof Object); //true alert(arguments instanceof Array); //false alert(arguments.callee.length);//实参长度,为2; alert(arguments.length);//形参长度,为1; if(arguments.length != arguments.callee.length){ //true alert(arguments[0]); //3 alert(arguments[1]); //undefined return false; } alert(arguments[0]); alert(arguments[1]); return x+y; };
2.caller:在函数内部使用,返回函数的反编译文本,若在函数外部使用,返回为null.
·栗子:
<script type="text/javascript"> window.onload = function(){ alert(add(3)); alert(add.caller); //null }; function add(x,y){ alert(add.caller); //返回反编译函数 if(arguments.length != arguments.callee.length){ return false; } return x+y; }; function plus(x,y){ return x-y; }; </script>
返回的反编译函数如下:
function(){ alert(add(3)); alert(add.caller);}
这里和toString()方法是有区别的:使用add.toString()方法返回如下,不论是在函数内调用还是在函数外调用:
function add(x,y){ alert(add.caller); //返回反编译函数 if(arguments.length != arguments.callee.length){ return false; } return x+y; };
0 0
- 【js】js中的隐藏对象arguments,caller,callee
- js中的arguments,caller,callee,apply
- js中的arguments,caller,callee,apply
- js中的arguments,caller,callee,apply
- js arguments和caller,callee
- js arguments.caller arguments.callee分析
- JS Function.caller 和 arguments.callee学习
- js arguments.callee.caller.…
- js中的caller和callee
- js中的caller和callee
- js中的callee和caller
- js函数的实参对象arguments 和其2个属性callee、caller
- JavaScript中的arguments,callee,caller
- JavaScript中的arguments、caller、callee
- js学习之arguments,callee,caller,call,appy 笔记
- js的arguments,callee,caller,length,prototype属性
- 关于js的隐含参数(arguments,callee,caller)
- js中arguments,caller,callee,apply的用法小结
- transitionFromViewController使用
- jQuery EasyUI使用教程之合并数据网格的单元格
- 华为oj 字符串个数统计&&数字颠倒&&字符串翻转&&字符逆序&&求int型数据在内存中存储时1的个数
- linux里的backlog详解
- 继承fragment 与 fragmentactivity的区别
- 【js】js中的隐藏对象arguments,caller,callee
- base64(Bitmap和base64的互换)
- 自定义View笔记——Canvas
- 泛型算法02
- UEditor 1.4.3版本中去掉本地保存功能
- C++第一次上机实验-1
- PS新手教程!教你绘制一枚通透质感的游戏按钮
- main执行前后
- js字符串操作