Can Ember.A() contain numbers/strings or it is suitable only for objects?


I’m trying to find out if Ember.A() can be used also with non-Objects. In the documentation, ethe strings are used in Enumerables together with pushObject() [e.g. in]

But when I try to add an empty string (as with push()), the value is not added. When I try to do replace, the item is removed from the array.

let arr = Ember.A(['first', 'second', 'third']);

arr.replace(0, 1, 'new-first');
arr.replace(1, 1, '');


try with pushObject


Thanks, pushObject() works as expected that makes it inconsistent. Originally, I had code with pushObject but then I shortened it to array initialization.

I need to replace/remove items from inside the array, so push(pop)Object does not work for me that well.


So, third parameter have to be collection. In later versions, you will see an assert that will warn you about it (thanks to Serabe and his PR#15814).


Correct solution is:

arr.replace(1, 1, ['']);