Is it better to use the map directive or a normal js array map? #4186
-
I noticed that in the Lit documentation under "Templates" -> "Lists" that they use a normal js array map in order to render an unordered list. However, there is also a map directive that accomplishes the same thing. My question is which one is better to use, and why is it better? Lit documentation use of js map: https://lit.dev/docs/templates/lists/#repeating-templates-with-map |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The primary difference is that the See https://lit.dev/tutorials/working-with-lists/#2 for more info! |
Beta Was this translation helpful? Give feedback.
The primary difference is that the
map
directive works with any iterable, including arrays, sets, maps, and even generators, whilstArray.prototype.map
only works on arrays. So it really depends on what iterable you are mapping over.See https://lit.dev/tutorials/working-with-lists/#2 for more info!