Add a property to a JavaScript array

arrays, javascript

Solution

var arr = [1,2,3,4,5];
arr.prop = 'value';

Arrays are already objects in JavaScript -- they just have some extra features and special literal syntax.

Problem

Arrays have a "length" property by default. Can I add custom properties to them? Without having to make them objects.

Original source

Related problems