W3cubDocs

/Ember.js

Ember.Enumerable (private)

Defined in: packages/ember-runtime/lib/mixins/enumerable.js:56
Module: ember

firstObject Object public

returns
Object
the object or undefined

Helper method returns the first object from a collection. This is usually used by bindings and other parts of the framework to extract a single object if the enumerable contains only one item.

If you override this method, you should implement it so that it will always return the same value each time it is called. If your enumerable contains only one object, this method should always return that object. If your enumerable is empty, this method should return undefined.

let arr = ['a', 'b', 'c'];
arr.get('firstObject');  // 'a'

let arr = [];
arr.get('firstObject');  // undefined

lastObject Object public

returns
Object
the last object or undefined

Helper method returns the last object from a collection. If your enumerable contains only one object, this method should always return that object. If your enumerable is empty, this method should return undefined.

let arr = ['a', 'b', 'c'];
arr.get('lastObject');  // 'c'

let arr = [];
arr.get('lastObject');  // undefined

© 2017 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://emberjs.com/api/ember/2.15/classes/Ember.Enumerable/properties