title: How can I add a key/value pair to a Javascript object when the value is empty?
body: <p>I need to add a new key to my Javascript object, obj.  Using the method below works fine as long as I have a value to go with the key.</p>
  
  <p>The method below inserts the actual characters "" into the value position.  I want to add the new item "key3", but I want it to now appear in obj as "key3":{} .</p>
  
  <p>Here is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    //1.adding key/value pair
      var obj ={
          "key1":{},
          "key2":{}
      };
      obj["key3"] = "test";
  
      //obj now looks like:
      obj ={
          "key1":{},
          "key2":{},
          "key3": test
      };
  
      //2.adding key/value pair with empty value
      var obj ={
          "key1":{},
          "key2":{}
      };
      obj["key3"] = "";
  
      //obj now looks like:
      obj ={
          "key1":{},
          "key2":{},
          "key3": ""
      };
  
      //but I want obj to look like:
      var obj ={
          "key1":{},
          "key2":{},
          "key3":{}
      };</code></pre>
  </div>
  </div>
  </p>