Nodejs Array Merge merge( key, array )

Here you can find the source of merge( key, array )

Method Source Code

Array.prototype.merge = function( key, array ){

  for( var i = 0; i < this.length; i++)
  {/*from  ww  w .ja v  a  2s  .  co m*/
    for(var j = 0; j < array.length; j++)
    {
      if( this[i][key] == array[j][key]) {

        for( var property in array[j] )
        {
          if( array[j].hasOwnProperty( property) && property != key)
          {
            this[i][property] = array[j][property];
          }
        }
      }
    }
  }
  return (this);
};

Related

  1. merge()
    Array.prototype.merge = function() {
      var l = this.length, a = [];
      for (var i=0; i<l; i++) {
        var k = this[i].length;
        for (var j=0; j<k; j++) {
          a.push(this[i][j]);
      return a;
    ...
    
  2. merge(arr)
    Array.prototype.merge = function(arr) {
        if (arr) {
            for (var i = 0; i < arr.length; ++i) {
                if (!this.contains(arr[i]))
                    this.push(arr[i]);
    
  3. merge(arr)
    Array.prototype.merge = function (arr) {
        if (arr == null || typeof(arr) == "undefined") {
            return this;
        return this.concat(arr);
    };
    
  4. merge(arra)
    Array.prototype.merge = function(arra){
        var oneArra = this;
        var twoArra = arra;
        var oneIndex = 0;
        var twoIndex = 0;
        var result = [];
        while(!(oneIndex == oneArra.length && twoIndex == twoArra.length)){
            if((oneArra[oneIndex] < twoArra[twoIndex]) || (twoIndex == twoArra.length)){
                result[result.length] = oneArra[oneIndex];
    ...