Variable 'tcb' should be initialized on declaration.
33 q: location.search,
34 }
35
36 var rcb, pcb, tcb // Save callbacks to apply later. 37 if (typeof(data.r) === 'function') rcb = data.r
38 if (typeof(data.t) === 'function') tcb = data.t
39 if (typeof(data.p) === 'function') pcb = data.p
Variable 'pcb' should be initialized on declaration.
33 q: location.search,
34 }
35
36 var rcb, pcb, tcb // Save callbacks to apply later. 37 if (typeof(data.r) === 'function') rcb = data.r
38 if (typeof(data.t) === 'function') tcb = data.t
39 if (typeof(data.p) === 'function') pcb = data.p
Variable 'rcb' should be initialized on declaration.
33 q: location.search,
34 }
35
36 var rcb, pcb, tcb // Save callbacks to apply later. 37 if (typeof(data.r) === 'function') rcb = data.r
38 if (typeof(data.t) === 'function') tcb = data.t
39 if (typeof(data.p) === 'function') pcb = data.p
Description
In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, foo
is initialized during declaration, while bar
is initialized later.
var foo = 1;
var bar;
if (foo) {
bar = 1;
} else {
bar = 2;
}
Bad Practice
function foo() {
var bar;
let baz;
}
Recommended
function foo() {
var bar = 1;
let baz = 2;
const qux = 3;
}