What is the value of var me = this;

extjs, javascript

Solution

One reason is because with minification, `me` can become much shorter than `this`.

Problem

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; }, ```

Original source