title: javascript Map object delete not working
body: <p>This is not the actual scenario but I have to use the check function as follows with conjunction with map object. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="" method="post" onsubmit="return check()"&gt;
  &lt;input type="text" name="name" id="one" oninput="change(this)" /&gt;
  &lt;input type="text" name="password" id="two" oninput="change(this)" /&gt;
  &lt;input type="submit" name="submit" value="submit" /&gt;
  &lt;/form&gt;
  &lt;script type="text/javascript"&gt;
  var map = new Map();
  function change(obj){
      var id = obj.id;
      if(obj.value != ""){
          map.set(id,obj.value);
          console.log("added key "+obj.id+" value "+obj.value+" size "+map.size);
      }else{
          map.delete[id];
          console.log("removed key "+obj.id+" value "+obj.value+" size "+map.size);
      }
  }
  
  function check(){
      if(map.size != 2){
          alert("enter all values");
          return false;
      }
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>The action in form tag is intentionally empty here</strong></p>
  
  <p>With the above code, when I enter values in any one text box, the value is added to the map but when I clear it again, the value pair is not deleting from the map. Size of the map is not decreasing on deleting it (or may be the object is not getting deleted). So once I clear the fields after entering something, the size of the map remains will be 2 and submit happens without any alert. Help me. The logic, I have to use it somewhere else to make it work. Thanks in advance.</p>