首页 > 代码库 > arguments
arguments
用于存储和访问函数参数的参数对象
公共属性:
1. callee:Function 当前正在执行函数的引用。
2. length:Number 参数数目。
递归函数尽量采用arguments,防止函数名有变化,导致错误。
function factorial(num){ if(num == 1) return 1; else return num * arguments.callee(num - 1);}document.write(factorial(10));
arguments 参数存储为数组元素
第一个为 arguments[0], 第二个 arguments[1], ...
function print(str){ document.write(arguments[0]); // Hello the world}print("Hello the world");
or
(function print(str){ document.write(arguments[0]); // Hello the world})("Hello the world");
arguments
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。