News for hackers. Stuff that matters.
Re:JavaScript quiz that may confuse you by glmdev on Wednesday May 04, 2022 @09:28AM (#31260072)
One particularly annoying case comes up when using IIFEs:

    let c = a + b
    (() => { ... })()
This is evaluated as:

    let c = a + (b(() => {...}))()
which usually results in "TypeError: b is not a function." Obviously this can be solved with a semicolon after the "let c..." line, but another common approach is to just prefix all IIFEs with semicolons, since empty statements are no-ops in JS:

    let c = a + b
    ;(() => {...})()
I personally prefer to forego semi-colons, but I have a hard time getting worked up over it either way.

There are no comments on this comment yet.