Skip to main content

Redundant use of this qualifier in the global context

In This Article

Note

The Redundant use of this qualifier in the global context code issue is JavaScript specific.

CodeRush Classic shows the Redundant use of this qualifier in the global context code issue if the “this” qualifier is redundant in the global context and can be removed.

#Fix

Remove the “this” qualifier.

#Purpose

Highlights the use of “this” qualifier in the global context, because the “this” qualifier should be used only within objects.

#Example

this.Clicks = 0;
var IncreaseClicks = new function () {
    Clicks++;
}

Fix:

var Clicks = 0;
var IncreaseClicks = new function () {
    Clicks++;
}