58 lines
1.1 KiB
Plaintext

== Why is this an issue?
When the keyword ``++this++`` is used outside of an object, it refers to the global ``++this++`` object, which is the same thing as the ``++window++`` object in a standard web page. Such uses could be confusing to maintainers. Instead, simply drop the ``++this++``, or replace it with ``++window++``; it will have the same effect and be more readable.
=== Noncompliant code example
[source,javascript]
----
this.foo = 1; // Noncompliant
console.log(this.foo); // Noncompliant
function MyObj() {
this.foo = 1; // Compliant
}
MyObj.func1 = function() {
if (this.foo == 1) { // Compliant
// ...
}
}
----
=== Compliant solution
[source,javascript]
----
foo = 1;
console.log(foo);
function MyObj() {
this.foo = 1;
}
MyObj.func1 = function() {
if (this.foo == 1) {
// ...
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]