Why send data to [] when calling the parent constructor?

I come from the C / C ++ syntax family, so some things here are not familiar to me.

constructor: function(manufacturer, model, topSpeed, maxAltitude){ // initialise our config object this.initConfig(); if(maxAltitude){ this.setMaxAltitude(maxAltitude); } // call the parent class' constructor this.callParent([manufacturer, model, topSpeed]); } 

So now, when I call the parent constructor, why do I include data in []? When I did something like this in C #, I just send data like in any normal function.

Could it be:

 this.callParent(manufacturer, model, topSpeed); 

This example from

Ext-JS 4 Web Application Development Book

but I think this is a JavaScript problem.

Thanks.

+4
source share
1 answer

Well .callParent() is the class system utility provided by ExtJS. It needs arguments as an array because it will use .apply() to call another function.

They could write it to build their own array if they wanted to. This is perhaps more useful in the current form, because it gives you more flexibility, and it is not like making an array complex in JavaScript.

(I do not know exactly what he is doing, because I do not use ExtJS.)

+3
source

Source: https://habr.com/ru/post/1432736/


All Articles