Skip to main content

Possibly unassigned variable usage

In This Article

Note

The Possibly unassigned variable usage code issue is JavaScript specific.

CodeRush Classic shows the Possibly unassigned variable usage code issue if a variable is called before it has been assigned.

#Fix

Assing the variable before the first call to it.

#Purpose

Highlights variables called before they are assigned, which can cause unexpected results.

#Example

var Multiply = new function (number) {
    var multiplier;
    return number * multiplier;
    multiplier= GetMultiplier();
}

Fix:

var Multiply = new function (number) {
    var multiplier= GetMultiplier();;
    return number * multiplier;
}