D
DaveC
Consider the following:
alert(typeof foo);
alert(typeof bar);
alert(typeof baz);
if (0) {
function foo() {
var a = 1;
}
var foo = 10;
var bar = function baz() {
var a = 1;
};
}
alert(typeof foo);
alert(typeof bar);
alert(typeof baz);
Which alerts:
Chrome: function, undefined, undefined, function, undefined, undefined
IE: function, undefined, function, function, undefined, function
Firefox: undefined, undefined, undefined, undefined, undefined,
undefined
Opera: function, undefined, undefined, function, undefined, undefined
Is the effect I'm seeing 'hoisting' (function declarations get
'hoisted' into their containing scope - except in Firefox)? And is
'hoisting' the correct term?
Thanks for any help.
Dave
alert(typeof foo);
alert(typeof bar);
alert(typeof baz);
if (0) {
function foo() {
var a = 1;
}
var foo = 10;
var bar = function baz() {
var a = 1;
};
}
alert(typeof foo);
alert(typeof bar);
alert(typeof baz);
Which alerts:
Chrome: function, undefined, undefined, function, undefined, undefined
IE: function, undefined, function, function, undefined, function
Firefox: undefined, undefined, undefined, undefined, undefined,
undefined
Opera: function, undefined, undefined, function, undefined, undefined
Is the effect I'm seeing 'hoisting' (function declarations get
'hoisted' into their containing scope - except in Firefox)? And is
'hoisting' the correct term?
Thanks for any help.
Dave