Nodejs Array Get Object getById(id)

Here you can find the source of getById(id)

Method Source Code

Array.prototype.getById = function(id) {
    for(var i=0; i<this.length; i++) {
        if(this[i]._id == id) {
            return this[i];
        }//  ww  w. jav  a 2  s. c  o m
    }
}

Related

  1. getByKey(aName)
    Array.prototype.getByKey = function(aName) {
        for(var i = this.length-1; i >= 0; i--)
            if(this[i].getKey() === aName)
                return this[i];
        return null;
    };
    
  2. getEach(code)
    Array.prototype.getEach = function(code){
        var rev = [];
        for(var i = 0 ; i < this.length ; i++){
            rev.push(this[i][code]);
        return rev;
    };
    
  3. getFrequency()
    Array.prototype.getFrequency=function(){
        this.sort()
        var count=0
        var max={
            val:0,
            num:0
        for (var i =1;i<this.length;i++){
            if(this[i]===""){
    ...
    
  4. getIndex(a)
    Array.prototype.getIndex=function(a){
      var index=-1;
      for(var i=0;i<this.length;i++){
        if(this[i]==a){
          index=i;
          break;
      return index;
    ...