Nodejs Array Find by ID findById(id)

Here you can find the source of findById(id)

Method Source Code

Array.prototype.findById = function (id) {
  for (var i = 0; i < this.length; i++) {
    if (this[i].id == id) {
      return i;/*  ww  w .  ja  v  a2s.co m*/
    }
  }
  return undefined;
};

Related

  1. findById(id)
    Array.prototype.findById = function(id) {
        for (var i = 0; i < this.length; i++) {
            if (this[i].id === id)
                return this[i];
        return false;