Start Date Release Date Release Versions PR link Tracking Link Stage Teams
3/24/2018 4/1/2019
  • ember-source: v3.9.0
  • Framework

array helper


This RFC proposes to add an array template helper for creating arrays in templates.

The helper would be invoked as (array arg1 ... argN) and return the value [arg1, ..., argN]. For example, (array 'a' 'b' 'c') would return the value ['a', 'b', 'c'].


Objects (or hashes) and arrays are the two main data structures in JavaScript. Ember already has a hash helper for building objects, so it makes sense to also include an array helper for building arrays.

Detailed design

The design is straightforward and mirrors the design of the hash helper. In particular, the important thing to note is that if any of the arguments to the array helper change then an entirely new array will be returned, rather than updating the existing array in place.

The implementation would also mirror the implementation of the hash helper and would simply capture the positional arguments instead.

How we teach this

This helper is not an important part of the programming model and can just be mentioned in the API docs like its sibling the hash helper.


As usual, adding new helpers increases the surface area of the API and file size but in this case it is justified because the file size change is extremely small and its actually filling an existing hole in the API.


This helper could be left to addons, and indeed there are addons that include this helper. It's also trivial to generate your own array helper with ember generate helper array. Humorously, the default helper blueprint generates a helper that already acts like the array helper ;)

Nevertheless, I believe it's preferable to include this helper in Ember to fill the hole in Ember's API.