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
-
Not entirely a goto since this still only allows structured control flow unlike real goto
But it's still a useful trick sometimes :D -
What‘s even the point? If you really need goto for some low level crap, which is already very, very unlikely, you‘d probably not use JS but C.
What's the freaking use case? -
only the second `continue label` here functions different from a plain continue, label2 is practically doing nothing
-
@Lensflare I think the intent is just escape inner loop to outer loop. So if you have a ton of loops maybe its an escape hatch. But a ton of inner loops kinda has a code smell to me.
-
kiki356222h@Demolishun there are complex algos that involve a lot of inner loops, and you know it. But why write them in JS in the first place when you have wasm
JS is a glue language -
Btw if you actually want to do this, use a do {} while(false) instead of a for, that way you don't have to remember to put a break at the end of each scope (for(;;) is an infinite loop)
-
@kiki any time I have done any looping in JS with even just a few thousand items it seems to get really slow. So I end up pushing the algo to C++. I use JS in a UI scripting situation with the bulk of the app in C++. If I need a multiloop algo I am not doing it in JS.
Even in C++ I don't need it that often. So I really need to evaluate if I need to do it in C++ as well. The most inefficient code I have ever written always involves nested loops. -
kiki356221h@Demolishun agree on all of the above. I do the same thing, but rn I'm mostly just using other people's wasm modules from github
ladies and gentlemen, goto in JS!
random