Nodejs Utililty Methods Array Find by Index

List of utility methods to do Array Find by Index

Description

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

Method

findIndex(callback)
'use strict';
Array.prototype.findIndex = Array.prototype.findIndex || function(callback) {
  if (this === null) {
    throw new TypeError('Array.prototype.findIndex called on null or undefined');
  } else if (typeof callback !== 'function') {
    throw new TypeError('callback must be a function');
  var list = Object(this);
  var length = list.length >>> 0;
...
findIndex(fn, v)
Array.prototype.findIndex = function(fn, v) {
    var isFN = typeof(fn) === 'function';
    var isV = v !== undefined;
    for (var i = 0, len = this.length; i < len; i++) {
        if (isFN) {
            if (fn(this[i], i)) {
                return i;
            continue;
...
findIndex(obj)
Array.prototype.findIndex = function (obj) {
  for (var i = 0, imax = this.length; i < imax; i++) {
    var ectypeObj = this[i];
    var ectypeObjLength = 0, successLength = 0;
    for (var k in ectypeObj) {
      ectypeObjLength += 1;
      if (ectypeObj[k] === obj[k]) {
        successLength += 1;
    if (ectypeObjLength === successLength) {
      return i;
  return -1;