Answer the question
In order to leave comments, you need to log in
What is this code doing in the loop?
for (const [node, linkedLayers] of groups) {}
groups is Map()
Do I understand correctly that the key flies to the node variable, and the values to linkedLayers . But why in square brackets instead of {}?
Answer the question
In order to leave comments, you need to log in
https://developer.mozilla.org/en/docs/Web/JavaScri...
read the section "Map iteration with for..of"
Why so? Well, because the built-in Map iterator returns an array of [key, value], those are the rules of the language. We can say that this is a shorthand for map.entries().
It also works in the opposite direction, such as
const first = new Map([
[1, 'one'],
[2, 'two'],
[3, 'three'],
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question