title: Test if an object exists JavaScript
body: <p>I can't believe this question would not have been asked before, but I searched as much as I could and couldn't find it so here it goes.</p>
  
  <p>I want to test if a dynamically built JavaScript object exists. However when I test this:</p>
  
  <pre><code>var myObject = {};
  var dynamicName = "customName";
  
  if(myObject[dynamicName].object == undefined){
    myObject[dynamicName].object = "something"; // Make an entry in the dynamic object
    alert("The object didn't exist, so we populated it");
  }else{
    alert("The object already exist");
  }
  </code></pre>
  
  <p>If the object doesn't exist and I try to run the above code I get an error saying "myObject[dynamicName] is undefined" and all javascript execution halts.</p>
  
  <p>Is there a way to check if this object exists I want without causing such an error?</p>