== Why is this an issue?

When a collection is empty with absolute certainty, it makes no sense to access or iterate it. Doing so can lead to unexpected behavior or errors in the code. The most common cause is that population was accidentally omitted or removed.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
const strings = [];

if (strings.includes("foo")) {}  // Noncompliant: strings is always empty

for (const str of strings) {}  // Noncompliant

strings.forEach(str => doSomething(str)); // Noncompliant
----

Make sure your code provides some way to populate the collection if their elements are to be accessed.

[source,javascript,diff-id=1,diff-type=compliant]
----
const strings = [];

strings.push("foo");

if (strings.includes("foo")) {}

for (const str of strings) {}

strings.forEach(str => doSomething(str));
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array[Array]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol[Iterable protocol]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Review this usage of '...' as it can only be empty here

=== Highlighting

the call or iteration

endif::env-github,rspecator-view[]
