Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the "arguments" variable come from in "this.callParent(arguments)"?

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?

like image 863
Shekhar Avatar asked Nov 21 '25 01:11

Shekhar


1 Answers

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.

like image 116
hopper Avatar answered Nov 23 '25 15:11

hopper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!