# Why {{array.\[index\]}} not working

**URL:** https://discuss.emberjs.com/t/why-array-index-not-working/8625
**Category:** Uncategorized
**Created:** [August 20, 2015, 1:41pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625 "2015-08-20T13:41:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![imaxhung](https://avatars.discourse-cdn.com/v4/letter/i/b487fb/32.png) [@imaxhung](https://discuss.emberjs.com/u/imaxhung)
#### Post date: [August 20, 2015, 1:41pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/1 "2015-08-20T13:41:49Z")

</div>

{{#each array as |item index|}}

{{anotherArray.[index]}}

It can not work.

Unless replacing index with explicit number

{{anotherArray.[0]}}

{{/each}}

Do I miss something?

---

<div class="post-metadata">

### Author: ![rwjblue](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rwjblue/32/9411_2.png) [@rwjblue](https://discuss.emberjs.com/u/rwjblue)
#### Post date: [August 20, 2015, 2:01pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/2 "2015-08-20T14:01:34Z")

</div>

Ember does not support all of handlebars syntax, this is one example.

You can do this with a helper though, simple version might look like:

```javascript
App.ObjectAtHelper = Ember.Helper.helper(function([array, index]) {
  return array[index];
});

```

[JSBin Demo](http://rwjblue.jsbin.com/pepuyo/edit?html,js,output)

---

<div class="post-metadata">

### Author: ![Wayne\_Douglas](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/wayne_douglas/32/9568_2.png) [@Wayne\_Douglas](https://discuss.emberjs.com/u/Wayne_Douglas)
#### Post date: [August 20, 2015, 2:02pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/3 "2015-08-20T14:02:17Z")

</div>

What about

```
{{#each array key="@index" as |item|}}

```

?

---

<div class="post-metadata">

### Author: ![imaxhung](https://avatars.discourse-cdn.com/v4/letter/i/b487fb/32.png) [@imaxhung](https://discuss.emberjs.com/u/imaxhung)
#### Post date: [August 20, 2015, 2:30pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/4 "2015-08-20T14:30:43Z")

</div>

Thank you.

Just think there should be a built-in way doing that thing.

Customize helper is very useful.

But I think ember.js should include those very very generic helpers to official helpers. It’s better than that everyone has to do this.

---

<div class="post-metadata">

### Author: ![rytis](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/rytis/32/11242_2.png) [@rytis](https://discuss.emberjs.com/u/rytis)
#### Post date: [August 21, 2015, 8:33am UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/5 "2015-08-21T08:33:30Z")

</div>

Try the get helper which has become available in Ember 2.0:

```
{{get anotherArray index}}

```

---

<div class="post-metadata">

### Author: ![dmoreno](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dmoreno/32/11093_2.png) [@dmoreno](https://discuss.emberjs.com/u/dmoreno)
#### Post date: [August 28, 2015, 6:12am UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/6 "2015-08-28T06:12:36Z")

</div>

A related open issue in htmlbars:

[https://github.com/tildeio/htmlbars/issues/388](https://github.com/tildeio/htmlbars/issues/388)

---

<div class="post-metadata">

### Author: ![DevinRhode2](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/devinrhode2/32/14826_2.png) [@DevinRhode2](https://discuss.emberjs.com/u/DevinRhode2)
#### Post date: [December 28, 2017, 4:05pm UTC](https://discuss.emberjs.com/t/why-array-index-not-working/8625/7 "2017-12-28T16:05:58Z")

</div>

If you get an error about index needing to be a string, simply do this: `(get items (concat index ""))`
