类数组对象 实参对象arguments

先看实参对象arguments

之前对argument有点印象,知道它不是真正的数组,但也可以arguments[0]和arguments.length。今天详细的记录一下。

js的默认行为:省略的实参是undefined,多余的实参自动忽略

function a(b,c){
   //把类数组对象转为数组
   console.log(Array.prototype.slice.call(arguments));
   console.log(arguments);
   console.log('b:'+b+';c:'+c);
  //arguments[0]可以改变b的值
   arguments[0] = 'sfp';
   console.log('b:'+b);
  //callee和caller调用方式不同
   console.log('callee:'+arguments.callee);
   console.log('caller:'+a.caller);
}
function test(){
  a(0);
  a(1,2,3);
}
test();

严格与非严格的区别

严格下,arguments是保留字;非严格下,arguments是标示符

callee和caller在严格下,读写错误;非严格下,callee 

 

类数组对象:犀牛书上没什么看的。

posted on 2015-08-17 11:32  j.w  阅读(216)  评论(0编辑  收藏  举报