Class Enumerable

private
Defined in: packages/ember-runtime/lib/mixins/enumerable.js:56
Module: @ember/enumerable
Since: vEmber 0.9

firstObject Object public

Module: @ember/enumerable
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

Module: @ember/enumerable
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

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