title: HTML page shows [object Object] after I pressed the button instead to show the results
body: <p>I was trying out some things to learn about how to work with constructors and objects. I wanted to create a page to show the input from the textfields using <strong>constructors</strong> and <strong>objects</strong> in Javascript. When I click on <strong>save</strong> it shows <strong>[object Object]</strong> on the HTML page. I tried some things but that failed.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Persons(name, age){
      this.name   = name;
      this.age = age;
  }
  
  var button  = document.querySelector('#save');
  
    
  
  function showPerson4(){
      var name   = document.querySelector("#name");
      var age = document.querySelector("#age");
  
      var person4    = new Persons();
      person4.name  = name;
      person4.age = age;
  
      document.querySelector("#person4").innerHTML = person4;
  
  
  }
  
  button.addEventListener("click", function (ev) {
      ev.preventDefault();
      showPerson4();
  },false);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Show person&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
      Name: &lt;input type="text" id="name" name="name" placeholder="Enter your name"&gt;&lt;br&gt;
      Age: &lt;input type="text" id="age" name="age" placeholder="Enter your age"&gt;
      &lt;button id="save" name="save"&gt;Save&lt;/button&gt;
      &lt;p id="person4" class="person4"&gt;&lt;/p&gt;
  
  &lt;script src="js/opdracht1.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>