title: How to find the size of map in javascript
body: <p>I want to print the size of map in javascript. I used the command <code>map.size</code> but the answer is coming 0 which is not correct.</p>
  
  <p>Here is my source code:</p>
  
  <pre><code>&lt;div id="demo" &gt;&lt;/div&gt;
  &lt;script&gt;
      function add(test, key, value) {
          if (!test[key]) 
              test[key] = [value];
          else 
              test[key].push(value);
      }
      var mapp = new Map();
      var i,j,k=0;
      for (i=0;i&lt;5;i++)
      {
        for (j=0;j&lt;i;j++)
        add(mapp,i,j);
      }
      document.getElementById('demo').innerHTML="Map size are: "+ mapp.size;
  &lt;/script&gt;
  </code></pre>
  
  <p>Output: <code>Map size are: 0</code></p>
  
  <p>However, when I am printing the map entries: </p>
  
  <pre><code>for (var m in mapp)
  {
          for (k=0;k&lt;mapp[m].length;k++)
          document.write(mapp[m][k]+"  ");
  
        document.write("&lt;br&gt;");
  }
  </code></pre>
  
  <p>I can see the output:  </p>
  
  <pre><code>0 
  0 1 
  0 1 2 
  0 1 2 3 
  </code></pre>
  
  <p>Please tell me how to find the size of map and why the above code <code>mapp.size</code> is not working.</p>