== Why is this an issue?

A collection is a data structure that holds multiple values, such as an array or a map. If a collection is declared and populated, but its values are never read anywhere in the code, it can be considered unused code. This can be due to some refactoring, copy-pasting, or typing errors.

Unused collections can waste memory usage and slow down the application's performance. Additionally, they can make the code harder to read and understand, especially for other developers working on the same codebase.


[source,javascript,diff-id=1,diff-type=noncompliant]
----
function getLength(a, b, c) {
  const strings = [];  // Noncompliant: Array is declared and populated but never read
  strings.push(a);
  strings.push(b);
  strings.push(c);

  return a.length + b.length + c.length;
}
----

Remove unused collections so that the application can run faster and more smoothly. The code becomes cleaner and more efficient, making it easier to read, understand, and maintain.

[source,javascript,diff-id=1,diff-type=compliant]
----
function getLength(a, b, c) {
  return a.length + b.length + c.length;
}
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections[Indexed collections]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections[Keyed collections]

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

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

=== Message

Either use this collection's contents or remove the collection.


=== Highlighting

primary: instantiation

secondary: population/depopulation


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