I tried to iterate over an es6 map like described here:
for (var [key, value] of myMap.entries()) {
console.log(key + " = " + value);
}
When running it with nodejs 4.1.2 and the --harmony flag I get
SyntaxError: Unexpected token [
I could write
for (var arr of myMap.entries()) {
console.log(arr[0] + " = " + arr[1]);
}
but this is not nice because it is not expressive.
Is there a better way?
This answer is made in accordance with this meta post.
As @Ben Fortune has commented:
Have you tried explicitly using the
--harmony_destructuringflag?
Actual documentation on this flag is hard to find, but more information can be found in this GitHub issue about destructuring assignment in node 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With