2

I'm working with a javascript (Ext JS 4) project, and I came across this:

{
    init: function() {
        var me = this, desktopCfg;
        ...
    }
}

What exactly is being assigned to 'me' in this situation?

1
  • 8
    I think I figured this out: It's basically initializing two variables but only supplying a value to the first Commented Dec 8, 2011 at 20:19

2 Answers 2

5

This:

var me = this, desktopCfg;

Is equivalent to:

var me = this;
var desktopCfg;

as = has higher precedence than ,.

See also: the manual for var which has examples of this syntax.

Sign up to request clarification or add additional context in comments.

Comments

1

the object this. the parser goes down the instructions and sees a comma separated list of the two instructions var me = this; desktopCfg; so the variable me gets the whole object that it is in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.