a();
function a() {
$('.doit').text('Text was replaced (a)');
}
if ($('.doit2').length) {
b();
function b() {
$('.doit2').text('Text was replaced (b)');
}
}
a()
is called correctly, while b
gives an error "b is not defined"
. Why?
(I've read about hoisting but function b
is declared, not a variable. Or am I wrong?)
See fiddle - Firefox is raising an error, while Chrome works.