
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.
47 lines
784 B
Plaintext
47 lines
784 B
Plaintext
== Why is this an issue?
|
|
|
|
If you have an iterable, such as an array, set, or list, your best option for looping through its values is the ``++for of++`` syntax. Use ``++for in++`` and you'll iterate the properties, rather than the values.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
const arr = [4, 3, 2, 1];
|
|
|
|
for (let value in arr) { // Noncompliant
|
|
console.log(value); // logs 0, 1, 2, 3
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
const arr = [4, 3, 2, 1];
|
|
|
|
for (let value of arr) {
|
|
console.log(value);
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Use "for...of" to iterate over this "xxx".
|
|
|
|
|
|
=== Highlighting
|
|
|
|
``++for (...)++``
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|