types of object

by black strings

HTML

<script src="https://cdn.jsdelivr.net/gh/eu81273/jsfiddle-console/console.js"></script>

JavaScript

class KitPlotterDetails {
  constructor(sku, kitName) {
    this.sku = sku;
    this.kitName = kitName;
  }
}

class WallPlotterDetails {
	constructor(blockHeight, capBlockHeight) {
  	this.blockHeight = blockHeight;
    this.capBlockHeight = capBlockHeight;
  }
}

class PaverPlotterMaterails {
	constructor(displayPattern, sandColor) {
  	this.displayPattern = displayPattern;
    this.sandColor = sandColor;
  }
}

function conform(pd) {
	// get unique names
	let names = [];

  pd.forEach(p => {
  	const name = p.constructor.name;
  	if(names.indexOf(name) < 0) {
    	names.push(name);
    }
  });
  console.log('unique names passed');
  
  // loop through each unique name and conform all objects
  const allUniquePD = [];
  names.forEach(name => {
  console.log('starting ' + name);
  
  	let unique = null;
    let isFirstFound = false;
  	pd.reduce((p,n) => {
    	const uniquePdName = p.constructor.name;
      if(uniquePdName) {
      	if(!isFirstFound && uniquePdName === name) {
          unique = p;
          allUniquePD.push(unique);
          isFirstFound = true;
        };
      }
    	
      if(isFirstFound && n && n.constructor.name === name) {
      	for (let [key, value] of Object.entries(unique)) {
          if(!value) {
            p[key] = n[key];
          }
        }
      }
      return unique ? unique : n;
    });
    console.log(name + " is completed");
  });
  
  console.log(allUniquePD);
  
}

var ploterDetails = [];

var wallPlotterDetails1 = new WallPlotterDetails(5);
var wallPlotterDetails2 = new WallPlotterDetails(undefined, 4);

var paverPlotterDetails1 = new PaverPlotterMaterails('pattern', null);
var patternPlotterDetails2 = new PaverPlotterMaterails(null, 'lightSand');

var kitPlotterDetails = new KitPlotterDetails(5,...