
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
52 lines
1.0 KiB
Plaintext
52 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
By convention, constructor function names should start with an upper case letter as a reminder that they should be called with the ``++new++`` keyword.
|
|
|
|
|
|
A function is considered to be a constructor when it sets all of its arguments as object properties, and returns no value.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
function person (firstName, middleInitial, lastName) { // Noncompliant
|
|
this.firstName = firstName;
|
|
this.middleInitial = middleInitial;
|
|
this.lastName = lastName;
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
function Person (firstName, middleInitial, lastName) {
|
|
this.firstName = firstName;
|
|
this.middleInitial = middleInitial;
|
|
this.lastName = lastName;
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Rename this constructor to "Xxx".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 12 Nov 2015, 18:25:33 Linda Martin wrote:
|
|
LGTM!
|
|
|
|
endif::env-github,rspecator-view[]
|