38 lines
742 B
Plaintext
Raw Normal View History

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.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
function Person(name, birthdate) {
this.name = name;
this.birthdate = birthdate;
get name() {
return name; // Noncompliant
}
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
function Person(name, birthdate) {
this.name = name;
this.birthdate = birthdate;
get name() {
return this.name;
}
}
----
ifdef::rspecator-view[]
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::rspecator-view[]