55 lines
966 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Using the ``++this++`` keyword inside the scope of an object to refer to the object's properties and methods yields cleaner, clearer code, and helps avoid confusion when there are variables or functions outside the object scope with the same or similar names.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
function Person(name, birthdate) {
this.name = name;
this.birthdate = birthdate;
get name() {
return name; // Noncompliant
}
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
function Person(name, birthdate) {
this.name = name;
this.birthdate = birthdate;
get name() {
return this.name;
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add "this" to this reference.
'''
== Comments And Links
(visible only on this page)
=== on 12 Nov 2015, 18:27:14 Linda Martin wrote:
OK!
endif::env-github,rspecator-view[]