Enumerable#firstObject

firstObjectObjectpublic

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

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

Returns:

Object
the object or undefined
doc_EmberJs
2016-11-30 16:51:57
Comments
Leave a Comment

Please login to continue.