当调用一个函数时,会为该函数创建一个Arguments对象,此对象即为arguments
例如:function f(x, y, z)
{
  if (arguments.length != 3)
   {
    throw new Error("参数不正确…");
   }
}但是下面这段代码:function check(args) {
var actual = args.length;
var expected = args.callee.length;
if {actual != expected) { 
  throw new Error("Wrong number of arguments: expected: " +
    expected + actually passed " + actual);
 }
)args又是什么东西呢?而且是以参数的形式存在,它是arguments吗?

解决方案 »

  1.   

    args是传过来的参数, 比如object,array,string等可以用length表示的数据结构,形参而已
      

  2.   

    一个参数吧。。callee是arguments对象的一个属性,不是参数的属性,你的这个函数有问题吧。javascript函数参数arguments,callee,caller
      

  3.   

    arguments 是参数集合function check(args)args 只是 arguments[0]
      

  4.   

    arguments 是最大的一个父级,args是它下面的长子。
    即 args == arguments[0]
      

  5.   


    此代码来自《JavaScript权威指南 第5版》8.6.1节144页,
    我就是看不懂诶!!
      

  6.   

    你没将代码发全,发全就明白你说什么了。。楼主还是要认真看下这章。。了解什么是callee    function check(args) {
            var actual = args.length;//为f函数中的arguments对象,实际传递给f的参数个数
            var expected = args.callee.length;//因为传递的是arguments对象,所以callee得到的就是函数f,而函数也是有length的,为(...)里面定义的参数的个数,只读,和arguments的length不一样
            if (actual != expected) {//实际传递的个数和f函数()中定义的个数不一样,就抛出错误。如f(1,2)少了一个参数或者f(1,2,3,4)多了一个参数,f(1,2,3)才是正确的
                throw new Error('Wrong number of arguments:expected:' + expected + ";actually passed" + actual);
            }
        }
        function f(x, y, z) {
            check(arguments);//传递f函数的arguments对象作为check函数的参数
            return x + y + x;
        }
      

  7.   

    我觉得lz完全没到 看 arguments call apply  prototype的时机
    把js的其他基础语法先看熟 多写点代码