Array#lastIndexOf()

lastIndexOf (object, startAt) Numberpublic

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

Returns the index of the given object's last occurrence. If no startAt argument is given, the search starts from the last position. If it's negative, will count backward from the end of the array. Returns -1 if no match is found.

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

arr.lastIndexOf('a');       //  4
arr.lastIndexOf('z');       // -1
arr.lastIndexOf('a', 2);    //  0
arr.lastIndexOf('a', -1);   //  4
arr.lastIndexOf('b', 3);    //  1
arr.lastIndexOf('a', 100);  //  4

Parameters:

object Object
the item to search for
startAt Number
optional starting location to search, default 0

Returns:

Number
index or -1 if not found
doc_EmberJs
2016-11-30 16:48:34
Comments
Leave a Comment

Please login to continue.