title: JavaScript array of classes behaving as clones?
body: <p>So I've been trying to implement a NEAT algorithm in JS, but I'm missing something because when I try to mutate the genomes in my population, they all come out with the same mutation, as in they behave as complete clones, every single genome is the same at the end. Not sure why the array of glasses seems to share connections and nodes when they each have been declared as a new object, I'm definitely missing something I just do not know what, here's the code:</p>
  
  <pre><code>    let startingNode = [];
  
        let inNode1 = new Node("INPUT", 0)
        let inNode2 = new Node("INPUT", 0)
        let outNode1 = new Node("OUTPUT", 100000)
  
        startingNode.push(inNode1);
        startingNode.push(inNode2);
        startingNode.push(outNode1);
  
        let startingGenome = new Genome([], startingNode);
  
        let population = new Population(20, startingGenome);    
  
  
  
  class Population {
  
            constructor(populationSize, startingGenome) {
  
              this.populationSize = populationSize;
              this.population = [];
  
              let genomeThings = startingGenome.copyGenome();
  
              while (this.population.length &lt; this.populationSize) {
                this.population.push(new Genome(genomeThings.connections, genomeThings.nodes));
              }
  
              this.mutate();
              console.log(this.population);
  
            }
  
            mutate() {
  
              for (let genome of this.population) {
                if (Math.random() &lt; MUTATION_RATE) {
                `genome.weightMutation()
                }
              }
  
            }
  
      class Genome {
  
        constructor(connections, nodes) {
          this.connections = connections;
          this.nodes = nodes;
        }
  
        copyGenome() {
          return {connections: this.connections, nodes: this.nodes};
        }
  </code></pre>