Nodejs Array Contain Object containsObjectById(id)

Here you can find the source of containsObjectById(id)

Method Source Code

/**/*from   ww  w  .j  a v a 2 s .  c o m*/
 * Returns true if array contains object with specified id, false otherwise
 * @memberof module:ArrayFunctions
 * @deprecated
 * @param {number} id Object's ID
 * @returns {boolean}
 */
Array.prototype.containsObjectById = function (id) {
    for (var i = 0; i < this.length; i++) {
        if (this[i].id === id) {
            return true;
        }
    }
    return false;
};

Related

  1. containsObject(obj)
    Array.prototype.containsObject = function(obj){
        var i;
        for (i = 0; i < this.length; i++) {
            if (this[i] === obj) {
                return true;
        return false;
    };
    ...
    
  2. containsObject(obj)
    Array.prototype.containsObject = function (obj) {
        var contains = false;
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                contains = true;
        return contains;
    };
    ...
    
  3. containsObject(obj)
    Array.prototype.containsObject=function(obj){
      var haveObj=false;
      for(var i=0;i<this.length;i++){
        if(this[i]==obj){
          haveObj=true;
          break;
      return haveObj;
    ...