Nodejs Utililty Methods Array Last Index

List of utility methods to do Array Last Index

Description

The list of methods to do Array Last Index are organized into topic(s).

Method

lastIndex(searchElement)
Array.prototype.lastIndexOf = function lastIndexOf(searchElement) {
  if (!(this instanceof Object)) {
    throw new TypeError(this + 'is not an object');
  var
  array = this,
  arrayIsString = array instanceof String,
  length = array.length,
  index = 1 in arguments ? Number(arguments[1]) || 0 : length - 1;
...
lastIndexOf(e)
Array.prototype.lastIndexOf = function (e) {
    for (var i = this.length - 1, j; j = this[i]; i--) {
        if (j == e) { return i; }
    return -1;
lastIndexOf(elem, from)
Array.prototype.lastIndexOf = function(elem, from) {
  if (from == null) {
    from = this.length - 1;
  } else if (from < 0) {
    from = Math.max(0, this.length + from);
  for (var i = from; i >= 0; i--) {
    if (this[i] === elem) {
      return i;
...
lastIndexOf(elt /*, from*/)
Array.prototype.lastIndexOf = Array.prototype.lastIndexOf || function(elt )  {
    var len = this.length;
    var from = Number(arguments[1]);
    if (isNaN(from)) {
        from = len - 1;
    } else {
        from = (from < 0)
            ? Math.ceil(from)
            : Math.floor(from);
...
lastIndexOf(item)
Array.prototype.lastIndexOf = function(item){
  var lastIndex = -1;
  for (var i=0; i<this.length; i++){
    if (this[i] === item){
      lastIndex = i;
  return lastIndex;
lastIndexOf(o)
Array.prototype.lastIndexOf = function (o) {
    var index = this.length;
    for (; index >= 0; index--) {
        if (index in this && this[index] === o)
            return index;
    return -1;
};
lastIndexOf(searchElement, fromIndex)
Array.prototype.lastIndexOf = function(searchElement, fromIndex) {
  if (!fromIndex || !isFinite(fromIndex)) {
    fromIndex = this.length - 1;
  for (var i = fromIndex; i >= 0; --i) {
    if (this.hasOwnProperty(i) && this[i] === searchElement) {
      return i;
  return -1;
lastIndexOf(v,b)
Array.prototype.lastIndexOf = function(v,b){
    var idx=-1;
  if(b===true && typeof(v)=="function"){
    for (var i=this.length-1;i>=0;i--) {
      if(v(this[i])){idx=i; break;}
  } else {
    for (var i=this.length-1;i>=0;i--) {
      if(this[i]===v){idx=i; break;}
...
lastIndexOf(value, begin, strict)
Array.prototype.lastIndexOf = function(value, begin, strict)
  begin = +begin || 0;
  var i = this.length;
  while(i-- > begin)
    if(this[i] === value || strict && this[i] == value )
      return i;
...