39 lines
810 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Object literal syntax, which initializes an object's properties inside the object declaration is cleaner and clearer than the alternative: creating an empty object, and then giving it properties one by one.
An issue is raised when the following pattern is met:
* An empty object is created.
* A consecutive single-line statement adds a property to the created object.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
let person = {}; // Noncompliant
person.firstName = "John";
person.middleInitial = "Q";
person.lastName = "Public";
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
let person = {
firstName: "John",
middleInitial: "Q",
lastName: "Public",
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]