4 ms·
> Besides, JS is the only language I know where half of it is recommended to not be used. That's what you get for having backward compatibility I guess. If the
by z3t4 9y ago
> Besides, JS is the only language I know where half of it is recommended to not be used.
That's what you get for having backward compatibility I guess. If the standards committee would break my old code I would probably quit and start a sect. I would call it "ReactReduxReduce" (RRR).
> The point is my students will forget the semicolon in some code that is not properly checked, and it will work. Most of the time. Until it doesn't.
Some people prefer writing JavaScript without semicolons. How do they not have bugs all over the place ? :P
- heavenlyblue 9y ago> Some people prefer writing JavaScript without semicolons. How do they not have bugs all over the place ? :P Some people prefer to have sex with children. How do they not get jailed?
- notsrg 9y agoUghhhh... what?
- heavenlyblue 9y agoIt's amusing how my karma went up and down depending on whether the given person had understood the joke or not; eventually normalising at exactly 1. Nevertheless - I can't blame them as there is no way to tell the irony on the net. Who I can blame is the original parent of this post who was quite confidently stating that omitting semicolons never causes any issues in his code (which is either a statement bounded by scale at which it works for him or it is not error-prone only in specific situations); and then just edited it so that it did not contain that specific line.
- wtetzner 9y ago> How do they not have bugs all over the place ? :P Who says they don't?
- WalterSear 9y agoThey don't.
- WorldMaker 9y ago> Some people prefer writing JavaScript without semicolons. How do they not have bugs all over the place ? The same way that people who write with semicolons avoid lots of bugs: linters and transpilers and tests. That said there is only one rule to remember when not writing semicolons, the easy to remember "winky frown" rule: all frowns must wink if they start a line/statement. ;( ;[ ;` ;(The last two are quite rare in my experience.) It's not that tough of a rule to remember.
- gknoy 9y agoOur projects' linting rules specify no semicolons, except when necessary; this means that we will _very rarely_ write something like this when we want to iterate over a small literal array: ;['foo', 'bar'].forEach(function (f) { it(`has an ${f} field`, function () { expect(......) }) } That said, we tend to use that construct extremely rarely, such as in a few test cases where we are doing the same kinds of things on two groups of items that need different descriptions.
- WorldMaker 9y agoMost of my usages are Typescript type assertions: ;(thing as Type).methodINeed() If it weren't for these I mostly wouldn't need semicolons at all, sometimes I refactor to: const thingType = thing as Type thingType.methodINeed()