This cannot be done in node.js because the current version of v8 did not implement iteration, as indicated in this error message .
We can confirm this by looking at the source code for v8 collection.js :
InstallFunctions($Map.prototype, DONT_ENUM, $Array( "get", MapGet, "set", MapSet, "has", MapHas, "delete", MapDelete, "clear", MapClear ));
But, as you can see in the ECMAScript 6 wiki , there should also be items() , keys() and values() . v8 probably did not use these methods before, because it did not support generators. But now he has been doing this May. It should just be a matter of time until it is implemented.
If you need to have this functionality now, you can use map-set-for-each , which populates forEach . You will need to modify it to add case 'symbol': after case 'object':
a.forEach(function(value, key) { if (value === 'Noise') { console.log('Give mak the bounty'); } });
When v8 implements the Map iteration, you can find Noise as follows:
for (let [key, value] of a) { if (value === 'Noise') { console.log('Upvotes for future'); } }
source share