Nodejs Array Index index(val)

Here you can find the source of index(val)

Method Source Code

Array.prototype.index = function(val) {
  for(var i = 0, l = this.length; i < l; i++) {
    if(this[i] == val) return i;
  }/*from  w ww.  j av a2s  . c o  m*/
  return null;
};

Related

  1. indexOf(value)
    Array.prototype.indexOf = function(value) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == value) {
          return index = i;
      return -1;
    };
    
  2. indexOf(value)
    Array.prototype.indexOf = function(value) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] === value) {
                return i;
    
  3. indexOf(value)
    Array.prototype.indexOf = function (value) {  
      for(var i=0; i<this.length; i++) {
        if(this[i] === value) {
          return i;
      return -1;
    
  4. indexOf(value, begin, strict)
    Array.prototype.indexOf = function(value, begin, strict)
      for(var i = +begin || 0; i < this.length; i++)
        if(this[i] === value || strict && this[i] == value)
          return i;
      return -1;
    };
    
  5. indexOf(what, i)
    Array.prototype.indexOf = function(what, i) {
            i = i || 0;
            var L = this.length;
            while (i < L) {
                if(this[i] === what) return i;
                ++i;
            return -1;
        };
    ...
    
  6. index(val)
    "use strict";
    Array.prototype.index = function(val) {
      for(var i = 0, l = this.length; i < l; i++) {
        if(this[i] == val) return i;
      return null;
    };
    
  7. indexOfAttr(attr, value)
    Array.prototype.indexOfAttr = function (attr, value) {
        for(var i = 0; i < this.length; i += 1) {
            if(this[i][attr] === value) {
                return i;
        return -1;
    };
    
  8. indexOfByFunction(filter)
    Array.prototype.indexOfByFunction = function (filter) {
        return indexOfByFunction(this, filter);
    };
    
  9. indexOfById(id)
    Array.prototype.indexOfById = function(id){
      var index = -1,
        i = 0,
        l = this.length,
        item;
      for(; l--; i++){
        item = this[i];
        if(parseInt(item.id) === id)
          return i;   
    ...