7
kiki
135d

ladies and gentlemen, goto in JS!

Comments
  • 5
    we're one step closer to doing Intel's JNZ in JS
  • 5
    Not entirely a goto since this still only allows structured control flow unlike real goto

    But it's still a useful trick sometimes :D
  • 3
    "JS considered harmful"
  • 5
    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?
  • 5
    @Lensflare there is none. I just thought it was funny
  • 3
    only the second `continue label` here functions different from a plain continue, label2 is practically doing nothing
  • 1
    @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
  • 2
    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)
  • 1
    Well, why not? :)
  • 1
    @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
Add Comment