javascript deleting properties of objects conditionally
<p>I have an object that may or may not have the properties I want to delete; the properties are added at runtime. This is how I'm writing the code:</p>

<pre><code>if (MyObject.hasOwnProperty("SomeProperty")) {
   delete MyObject['SomeProperty'];
}
</code></pre>

<p>If I remove the condition to test if the property doesn't exist, the code doesn't crash but I'm wondering if this is just because I'm running it in Chrome or if it's valid javascript. In other words, can I write <code>delete MyObject['SomeProperty'];</code> without the <code>.hasOwnProperty</code> statement and be fine even when the object won't have the property.</p>

<p>Thanks.</p>
