Enumerable#find()

find (callback, target) Objectpublic

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

Returns the first item in the array for which the callback returns true. This method works similar to the filter() method defined in JavaScript 1.6 except that it will stop working on the array once a match is found.

The callback method you provide should have the following signature (all parameters are optional):

function(item, index, enumerable);
  • item is the current item in the iteration.
  • index is the current index in the iteration.
  • enumerable is the enumerable object itself.

It should return the true to include the item in the results, false otherwise.

Note that in addition to a callback, you can also pass an optional target object that will be set as this on the context. This is a good way to give your iterator function access to the current object.

Parameters:

callback Function
The callback to execute
target [Object]
The target object to use

Returns:

Object
Found item or `undefined`.
doc_EmberJs
2016-11-30 16:51:57
Comments
Leave a Comment

Please login to continue.