A
André Hänsel
Hi,
I am using ExtJS but this should make no difference. I am wondering
why this:
function init() {
var w = {};
w = new Ext.Window({
items: {
keys:{
key: Ext.EventObject.ENTER,
fn: function(){ this.save(); },
scope: w
},
},
save: function()
{
console.log('save');
}
});
}
is different from this:
function init() {
var test;
var w = new Ext.Window({
items: {
keys:{
key: Ext.EventObject.ENTER,
fn: function(){ this.save(); },
scope: test
},
},
save: function()
{
console.log('save');
}
});
test = w;
}
In the first example the scope of the innermost anonymous function (w)
is the empty object while in the second example it's the Ext.Window
object.
Aren't w and test in the same scope? So the additional assignment
shouldn't be necessary, should it?
Regards,
André
I am using ExtJS but this should make no difference. I am wondering
why this:
function init() {
var w = {};
w = new Ext.Window({
items: {
keys:{
key: Ext.EventObject.ENTER,
fn: function(){ this.save(); },
scope: w
},
},
save: function()
{
console.log('save');
}
});
}
is different from this:
function init() {
var test;
var w = new Ext.Window({
items: {
keys:{
key: Ext.EventObject.ENTER,
fn: function(){ this.save(); },
scope: test
},
},
save: function()
{
console.log('save');
}
});
test = w;
}
In the first example the scope of the innermost anonymous function (w)
is the empty object while in the second example it's the Ext.Window
object.
Aren't w and test in the same scope? So the additional assignment
shouldn't be necessary, should it?
Regards,
André