码迷,mamicode.com
首页 > 编程语言 > 详细

类数组对象 实参对象arguments

时间:2015-08-17 13:36:12      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

先看实参对象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 

 

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

类数组对象 实参对象arguments

标签:

原文地址:http://www.cnblogs.com/wang-jing/p/4736172.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!