Reputation: 14048
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?
Upvotes: 2
Views: 930
Reputation: 5264
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.
Upvotes: 1
Reputation: 943967
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.
Upvotes: 5