title: Object oriented javascript with prototypes vs closures
body: <p>I'm curious what the difference is between the following OOP javascript techniques. They seem to end up doing the same thing but is one considered better than the other?</p>
  
  <pre><code>function Book(title) {
      this.title = title;
  }
  
  Book.prototype.getTitle = function () {
      return this.title;
  };
  
  var myBook = new Book('War and Peace');
  alert(myBook.getTitle())
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>function Book(title) {
      var book = {
          title: title
      };
      book.getTitle = function () {
          return this.title;
      };
      return book;
  }
  
  var myBook = Book('War and Peace');
  alert(myBook.getTitle())
  </code></pre>