3

While learning ExtJS 4, I found out that while defining a new class, in the initComponent method the constructor of the parent class can be called using this.callParent(arguments).

I would like to know where this arguments variable (I know it can be args or a or arg too) is defined, and where its value is assigned.

For example, if I define my class as follows:

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);
  }

});

Does anyone know where this arguments variable is defined, and how values are assigned to it?

hopper
  • 13,060
  • 7
  • 49
  • 53
Shekhar
  • 11,438
  • 36
  • 130
  • 186

1 Answers1

7

The arguments variable is a special variable in Javascript, available within any function. It's not a true array, but it contains the argument values passed to the function which can be accessed like array elements (so, arguments[0] is the first argument, arguments[1] is the second, and so on).

Check out this page on the Mozilla Developer Network for more information and examples.

hopper
  • 13,060
  • 7
  • 49
  • 53