(1)caller 表示调用该函数的函数
(2)
function fun1() {
return arguments.callee.caller.arguments[0]; //或写作: fun1.caller.arguments[0];
}
function fun2() {
alert(fun1());
}
fun2(11, 22); //11
(2)
function Foo(){}
var foo = new Foo
var p = Foo.prototype
Foo.prototype={}
alert(foo.constructor)
alert(Foo.prototype.constructor)
alert(p.constructor);
alert(Foo.prototype == p);
alert(Foo.prototype.constructor==foo.constructor);
alert(p.constructor==foo.constructor);
本文探讨了JavaScript中caller属性的使用方式,并通过实例展示了如何访问调用当前函数的上一层函数的参数。此外,还深入研究了通过构造函数创建对象及原型链的相关概念。
171

被折叠的 条评论
为什么被折叠?



