I find this pattern all over the ExtJS source code.
method: function() {
var me = this;
...
me.someOtherMethod();
}
Why don’t they just use this? Is there some advantage to always often defining me (outside of not having to type 2 characters)? I can understand if they are trying to maintain the context via closure, but it’s done in places where there is no closure at all.
An example from Ext.panel.Panel:
disable: function(silent) {
var me = this;
if (me.rendered) {
me.el.addCls(me.disabledCls);
me.el.dom.disabled = true;
me.onDisable();
}
me.disabled = true;
if (silent !== true) {
me.fireEvent('disable', me);
}
return me;
},
One reason is because with minification,
mecan become much shorter thanthis.