Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
This is just about the only use for this, unless you're iterating matrices you definitely don't need a nested loop in a single function.
-
kamen69965y@Lor-inc There are a lot of other uses for nested loops, i.e. comparing two arrays element by element. Of course you can use Array.map() and whatnot, but those are usually just abstracting away the fact that some kind of a loop is still used internally.
-
@kamen Use a method. Don't write ambivalent code and rely on your sense of what needs to be explained, create tiny methods and ensure that variable lifespan is the shortest possible.
-
Marl3x27795y@PrivateGER Svelte does this. Well, not really. They use this feature that absolutely nobody knows about to mark their variables syntactically, and because it's valid Javascript it will work even if not using their compiler. There is a talk about it on YouTube. I found it pretty fascinating.
Related Rants
I have just learnt that you can label for statements and break them in an inside loop
Wakanda crazy crap is this?
fyi here is an example:```js
outerLoop:for(let i = 0; i<5; i++){
for(let j=0; j<5; j++){
console.log(i*j);
if(i*j === 8) { break outerLoop;}
}
}
```
Why do we even set a label with a colon, why?
joke/meme
js
stew