I'm using Map in NodeJS 0.10.36 by enabling harmony flag. I'm able to create a map, set and get data, but other methods like size, keys(), entries(), forEach yield undefined results.
var k = new Map();
k.set('a', 1);
k.set('b', 2);
console.log('Printing out b', k.get('b')); //prints 2
var length = k.size;
console.log('Size of my map', length); // prints undefined
for(var key in k.keys()) {
console.log('keys value',key);
} // undefined
Is there something that I could do to make it work?
You have an old Node version. My Node (0.12.4) prints
2
fork.size
.k.keys()
should be iterated withof
, not within
:tl;dr: Upgrade Node.