在学习ExtJS 4时,我发现在定义一个新类时,可以在initComponent
方法中使用this.callParent(arguments)
调用父类的构造函数。
我想知道这个arguments
变量(我也知道它也可以是args
或a
或arg
)在哪里定义,以及它的值分配在哪里。
例如,如果我按以下方式定义我的类(class):
Ext.define('shekhar.MyWindow', {
extend : 'Ext.Window',
title : 'This is title',
initComponent : function() {
this.items = [
// whatever controls to be displayed in window
];
// I have not defined argument variable anywhere
// but still ExtJS will render this window properly without any error
this.callParent(arguments);
}
});
有谁知道这个
arguments
变量的定义位置以及如何为其赋值? 最佳答案
arguments
变量是Javascript中的特殊变量,可在任何函数中使用。它不是一个真正的数组,但是包含传递给函数的参数值,可以像数组元素一样对其进行访问(因此,arguments[0]
是第一个参数,arguments[1]
是第二个参数,依此类推)。
在Mozilla开发人员网络上查看this page,以获取更多信息和示例。