Nodejs Array Find Object findObjectByName(nameOfObj)

Here you can find the source of findObjectByName(nameOfObj)

Method Source Code

Array.prototype.findObjectByName = function (nameOfObj) {
   for(var i=0; i<this.length;i++ ){ 
        if(this[i].name==nameOfObj){
           return this[i];
        }/*www. jav a 2 s . com*/
   } 
   return null;
}


/*
Array.prototype.removeByElement(element){
   for(var i=0; i<this.length;i++ ){ 
        if(this[i]==element)
           this.splice(i,1); 
   } 
};

Array.prototype.findObjectByName(nameOfObj){
   for(var i=0; i<this.length;i++ ){ 
        if(this[i].name==nameOfObj){
           return this[i];
        }
   } 
   return null;
};*/

Related

  1. findObject(value, key)
    Array.prototype.findObject = function (value, key) {
        var found = false;
        for (var i = 0; i < this.length; i++) {
            if (this[i][key] == value) {
                found = true;
        return found;
    };
    ...
    
  2. findObject(value, key)
    Array.prototype.findObject = function (value, key) {
      var found = -1;
      for (var i = 0; i < this.length; i++) {
        if (this[i][key] == value) {
          found = this[i];
      return found;
    };
    ...
    
  3. findObject(value, key)
    Array.prototype.findObject = function (value, key) {
        var my_obj = null;
        for (var i = 0; i < this.length; i++) {
            if (this[i][key] == value) {
                my_obj = this[i];
        return my_obj;
    };
    ...