Why me

No, it’s not a rhetorical question!

Have you ever wondered what this means?

    var me = this;

If you used ExtJs, you probably have.
The main reason it’s done this way is that you can later use ‘me’ without worrying about your current scope, in event handlers and such. Of course, these two ways are equivalent:

    this.on('render', function() {
    }, this);


    var me = this;
    me.on('render', function() {

You could say: well, in ExtJs I can usually set the scope for any listeners and handlers myself! Why bother with “me”?
Well, aside from convenience, there’s one more reason: minification.

When JS code is minified, this is not replaced. And it’s four symbols. And it’s usually everywhere. Guess what? Me can be minified, and this can save quite some bytes!

So, me is for me. What do you think?


About Maryna Cherniavska

I have productively spent 10+ years in IT industry, designing, developing, building and deploying desktop and web applications, designing database structures and otherwise proving that females have a place among software developers. And this is a good place.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s