# Manually populating arrays?

**URL:** <https://forum.electromage.com/t/manually-populating-arrays/361>\
**Category:** Patterns and Code\
**Created:** [May 13, 2020, 10:37pm UTC](https://forum.electromage.com/t/manually-populating-arrays/361 "2020-05-13T22:37:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jeff](https://forum.electromage.com/user_avatar/forum.electromage.com/jeff/32/3473_2.png) [@jeff](https://forum.electromage.com/u/jeff)\
**Post date:** [May 14, 2020, 4:59am UTC](https://forum.electromage.com/t/manually-populating-arrays/361/2 "2020-05-14T04:59:10Z")

</div>

Hey John,

_[Edit: as of Oct '21’s firmware v3.2 and 2.28, [array literals](https://forum.electromage.com/t/v3-20-release-array-literals-bugfixes-and-more/1640) are now supported!]_

Array literals aren’t yet supported. Wizard (Ben) said it makes memory management harder and would require implementing a garbage collector.

So, to populate a 3x3, I would do this:

```javascript
themes = array(3)
for (i = 0; i < 3; i++) themes[i] = array(3)
themes[0][0] = a
themes[0][1] = b
// etc

```

Sometimes I write a helper to let me to set a row compactly with arguments separated by commas.

```javascript
assignRow3Col = (arr, r, c0, c1, c2) => { arr[r][0] = c0; arr[r][1] = c1; arr[r][2] = c2 }
assignRow3Col(themes, 0, a, b, c)

```

Or

```javascript
assign3 = (c0, c1, c2) => { 
  arr = array(3)
  arr[0] = c0; arr[1] = c1; arr[2] = c2
  return arr 
}
themes[0] = assign3(a, b, c)

```

---

_[View the full topic](https://forum.electromage.com/t/manually-populating-arrays/361)._
