The second and third snippet are functionally equivalent. callParent
is just a cleaner and simpler way to invoke the parent's function instead of going through the superclass
property.
The first example is completely different. For one, it does not call the parent's constructor. This is usually bad news. The base class usually has some initialization that needs to get done, and forgetting to call the parent for constructor (and initComponent) is a common source of bugs.
initConfig
is a convenience method which will:
- merge your object's initial config with the config that is passed in
- create getters and setters for all properties in the config
- apply the config to the object
This is entirely different from invoking the parent constructor. What invoking the parent constructor does is entirely dependent on what it's written to do. Some will use initConfig
, some won't, and others will do similar things that initConfig does, but manually.
It's not necessary to use initConfig
, and it's even dangerous at times. But that's another story altogether (for Ext 4.1, initConfig looks to be hopefully harmless and not contain the same dangerous side effects that it has in 4.0)
Side Note
Just to point out. In the second and third snippet, the constructor is not needed. If your constructor is only calling the parent's constructor, then you can leave your constructor out altogether.