Array#objectAt()

objectAt (idx) *public

Defined in packages/ember-runtime/lib/mixins/array.js:225

Returns the object at the given index. If the given index is negative or is greater or equal than the array length, returns undefined.

This is one of the primitives you must implement to support Ember.Array. If your object supports retrieving the value of an array item using get() (i.e. myArray.get(0)), then you do not need to implement this method yourself.

let arr = ['a', 'b', 'c', 'd'];

arr.objectAt(0);   // 'a'
arr.objectAt(3);   // 'd'
arr.objectAt(-1);  // undefined
arr.objectAt(4);   // undefined
arr.objectAt(5);   // undefined

Parameters:

idx Number
The index of the item to return.

Returns:

*
item at index or undefined
doc_EmberJs
2016-11-30 16:48:35
Comments
Leave a Comment

Please login to continue.