title: Can't access a object property of an array element, inside a object in javascript
body: <p>I have an array of objects inside an object.</p>
  
  <p>Why do I get the error 'Cannot read property fname of undefined' below?  How do I fix it?</p>
  
  <p>Also, I'm new to javascript and would appreciate any styling or convention suggestions.</p>
  
  <p><a href="https://jsfiddle.net/go1eu9z6/" rel="nofollow noreferrer">https://jsfiddle.net/go1eu9z6/</a></p>
  
  <pre><code>function myObj() {
    this.X = [],
  
      this.haveEntries = function() {
        return this.A.length &gt; 0;
      },
  
      this.add = function(fname_in, lname_in, city_in) {
        var t = new Date().getTime() / 1000;
  
        var obj = {
          fname: fname_in,
          lname: lname_in,
          city: city_in,
          t_create: t
        };
  
        this.X.push(obj);
  
        return this;
      }
  }
  
  var AB = {};
  AB.X = new myObj();
  
  AB.X.add("mike", 'smith', 'Toronto');
  
  var s = AB.X[0].fname; // Error:  Cannot read property fname of undefined
  
  document.getElementById('fname').innerHTML = s
  </code></pre>