title: Using Arrays in a JavaScript class
body: <p>I have a JavaScript class defined as shown here:</p>
  
  <pre><code>function Item() { 
    this.init(); 
  } 
  
  Item.prototype = { 
    id: null, 
    name: '', 
    description: '', 
    init: function () { 
      this.id = "1"; 
    } 
  };
  </code></pre>
  
  <p>I want to add a property called "logs". I want this property to be an array of other class entities. How do I define this kind of array as a property on my Item class? How do I add entities to that array? Originally, I thought I could add "this.logs = {};" in my init function. Then in my code elsewhere, I tried the following:</p>
  
  <pre><code>Item i = new Item();
  i.logs.push(NewLog());
  </code></pre>
  
  <p>However, the push function through an error that says: "Cannot call method 'push' of undefined"</p>
  
  <p>What am I doing wrong?</p>