I’m coming from C/C++ syntax family so some things here aren’t 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’m calling a parent’s constructor, why am I including data in []? When I did something similar in C#, I just send data like in any normal function.
Couldn’t this just be:
this.callParent(manufacturer, model, topSpeed);
This example is from
Ext-JS 4 Web Application Development Cookbook
but I think it’s a JavaScript problem.
Thank you.
Well
.callParent()is a class system utility provided by ExtJS. It needs the arguments as an array because it’s going to use.apply()to call another function.They could have written it to build its own array if they’d wanted to. It’s arguably more useful in the current form because it gives you more flexibility, and it’s not like making an array is hard in JavaScript.
(I don’t know exactly what it does because I don’t use ExtJS.)