[英]why arguments object is not showing it's method in console
Take a look at this code: 看一下这段代码:
var args;
function foo(){
args = arguments;
}
foo();
console.log(args); // []
args.callee(); // foo
how come I'm not able to see any property or method of arguments object in console yet able to call callee method ? 为什么在控制台中看不到参数对象的任何属性或方法,却能够调用被调用方方法呢?
You are not passing foo
any arguments. 您没有向
foo
传递任何参数。 Also, The callee
property is "non-enumerable". 同样,
callee
属性是“不可枚举的”。
Disclaimer: this assumes you're using the Chrome or Firebug consoles, there is no standard, so custom consoles might do funky things. 免责声明:这是假设您使用的是Chrome或Firebug控制台,没有标准配置,因此自定义控制台可能会做一些时髦的事情。
Because you used console.log
which displays array-like* objects differently from "plain" objects. 因为您使用了
console.log
,它显示的类似于数组的对象与“普通”对象不同。 If you want to see the properties on the object, use console.dir
. 如果要查看对象的属性,请使用
console.dir
。
* to be array-like the object has to have a length
property and splice
function, or a number of other niche conditions. *要像数组一样,对象必须具有
length
属性和splice
函数,或者具有许多其他特殊条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.