JavaScript/Using arrays to store other properties
[i]Learn· Indexed collections

Using arrays to store other properties

Arrays can also be used like objects, to store related information.

const arr = [1, 2, 3];
arr.property = "value";
console.log(arr.property); // "value"

For example, when an array is the result of a match between a regular expression and a string, the array returns properties and elements that provide information about the match. An array is the return value of RegExp.prototype.exec(), String.prototype.match(), and String.prototype.split(). For information on using arrays with regular expressions, see Regular Expressions.

Source: Indexed collections by Mozilla Contributors, licensed under CC-BY-SA-2.5. Retrieved 2026-11-18. Changes: Extracted the section "Using arrays to store other properties"; removed the code-block language labels; made links absolute; examples are the page's own code blocks, unchanged.