title: In the vis.js library, how do I get the max value in the "id" field?
body: <p>I'm discovering vis.js, especially the network module.</p>
  
  <p>I need to get the max value of the "id" field of my nodes dataset:  </p>
  
  <pre><code>var nodes = new vis.DataSet([ {id: 1, label: "Node 1"}, {id: 2, label: "Node 2"}, {id: 3, label: "Node 3"}]);
  </code></pre>
  
  <p>The best I've been able to do so far is using a forEach loop:  </p>
  
  <pre><code>var max=0;
  nodes.forEach(function(el){j=parseInt(el.id);if(j!=NaN &amp;&amp; j&gt;max){max=j;}});
  console.log("max: ", max);
  </code></pre>
  
  <p>It seems to me it can't be THE way to do this.
  I saw a <code>max(field)</code> method documented in the doc for vis' DataSet (<a href="https://visjs.github.io/vis-data/data/dataset.html" rel="nofollow noreferrer">https://visjs.github.io/vis-data/data/dataset.html</a>):  </p>
  
  <blockquote>
    <p>max(field) [Object|null]  Find the item with maximum value of specified field. Returns null if no item is found. </p>
  </blockquote>
  
  <p>But as stupid as i may sound, I just can't get it to work.
  I tried :  </p>
  
  <pre><code>console.log("max: ", nodes.max('id'));
  console.log("max: ", nodes.max(node =&gt; node.id));
  console.log("max: ", nodes.max(node =&gt; node['id']));
  </code></pre>
  
  <p>How can I simply get the max value of the field 'id' of all entries of a DataSet?</p>
  
  <p><strong>[Edit]</strong> The ID's in the example here above are numeric (<code>{id: 1, ...}</code>).<br>
  In my case, they were strings (<code>{id: '1', ...}</code>), and exactly that seemed to be the problem.</p>