How can I check if two Map objects are equal?
<p>How can I check if two <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" rel="noreferrer">ES2015 Map</a> objects have the same set of <code>(key, value)</code> pairs?</p>

<p>We can assume that all the keys and values are primitive datatypes.</p>

<p>One approach to solve this would be to take the <code>map.entries()</code>, create array from it, then sort that array by keys. And do the same thing with the other map. And then loop through those two arrays to compare them. All this seams cumbersome and also very inefficient because of sorting (performance inefficiency) and because of making those arrays (memory inefficiency).</p>

<p>Does anybody have better idea?</p>