3 ms·
Good examples actually. (Makes me feel better about my ingrained semicolon habit.) Your examples will crash immediately and at the right spot though. The probl
by Tloewald 13y ago
Good examples actually. (Makes me feel better about my ingrained semicolon habit.)
Your examples will crash immediately and at the right spot though. The problems I see caused by excessive use of semicolons are often far weirder.
That said, inadvertent errors caused by semicolon insertion are still more common and baffling (especially by people addicted to jslint who use a variable declaration idiom particularly easy to screw up with errant semicolons).
- mistercow 13y agoThe first example won't crash if the rvalue preceding the IIFE is a higher-order function (specifically, one that outputs a function). A relatively rare scenario, but a brutal one to debug. As for errors caused by extra semicolons, they can be weird, but I don't think I've ever actually hit one in practice. They'd also be a little easier to spot, since you tend to develop a reasonable instinct for where semicolons belong.
- Tloewald 13y agoI'd say it's a lot easier to be suspicious of lines of code that start with '(' or '[' than find semicolons at the end of the wrong line. It's incredibly easy to put a semicolon where a comma is expected and vice versa. I do it all the time (usually causing an immediate error so it's not a huge deal).