48 lines
771 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
When an object is created with a setter for a property but without a getter for that property, the property is inaccessible and is thus useless.
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
This rule also enforces the reverse situation (getter but no setter).
== Noncompliant Code Example
----
var obj = {
set foo(value) {
this.fooval = value;
}
};
----
== Compliant Solution
----
var obj = {
set foo(value) {
this.fooval = value;
},
get foo() {
return this.fooval;
}
};
----
or
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
----
var obj = {
setFoo(value) { // a standard method, not a setter
this.fooval = value;
}
};
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]