5 Matching Annotations
- Oct 2020
-
-
A reasonably clean alternative would be to map a function over the array and use destructuring in the each loop: {#each [1, 2, 3, 4].map(n => ({ n, sqr_n: n * n })) as { n, sqr_n }} {sqr_n} {sqr_n / 2}<br> {/each}
-
Could I get your intuition for why that rule of thumb applies to svelte components but not Javascript functions? I tend to make heavy use of let x = e when writing normal Javascript, as I do in most other languages (though unlambda is a notable exception). How is svelte different?
-
-
github.com github.com
-
I discovered that a solution can be hacked using an {#if}, but a proper one would be nice:
-
-
-
About the argument against it, "{@const will make code less consistent ": I think the same is true now, since people can come up with very different ways of dealing with the "computed value inside each loop/if function" problem. Some extract components, some use functions, some will prepare the array differently beforehand.
-