title: JavaScript Array of Key/Value Pairs Uses Literal Variable Name for Key
body: <p>I'm trying to create an array of key/value pairs by using the <code>push</code> method, but getting unexpected results.</p>
  
  <p><code>console.log</code> prints this:</p>
  
  <blockquote>
    <p>books: [{"bookTitle":"Mark Twain"}]</p>
  </blockquote>
  
  <p>Whereas I would expect this:</p>
  
  <blockquote>
    <p>books: [{"Tom Sawyer" : "Mark Twain"}]</p>
  </blockquote>
  
  <p>Here's the code:</p>
  
  <pre><code>var books = [];
  var bookTitle = "Tom Sawyer";
  var author = "Mark Twain";
  
  books.push({bookTitle : author})
  
  console.log("books: %s", JSON.stringify(books))
  </code></pre>
  
  <p>I've tried <code>books.bookTitle = author</code> and <code>books[bookTitle] = author</code>, but the result is the same.  Any help is appreciated.</p>