News for hackers. Stuff that matters.
Re:JavaScript for People Who Hate JavaScript by z3t4 on Wednesday August 09, 2017 @07:22AM (#14967477)
> 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

Re:JavaScript for People Who Hate JavaScript by WorldMaker on Wednesday August 09, 2017 @10:38AM (#14969409)
> 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.

Re:JavaScript for People Who Hate JavaScript by gknoy on Wednesday August 09, 2017 @06:04PM (#14974148)
Our 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.
Re:JavaScript for People Who Hate JavaScript by WorldMaker on Thursday August 10, 2017 @11:13AM (#14980492)
Most 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()
Re:JavaScript for People Who Hate JavaScript by wtetzner on Wednesday August 09, 2017 @10:04AM (#14968915)
> How do they not have bugs all over the place ? :P

Who says they don't?

Re:JavaScript for People Who Hate JavaScript by WalterSear on Wednesday August 09, 2017 @10:25AM (#14969190)
They don't.
Re:JavaScript for People Who Hate JavaScript by heavenlyblue on Wednesday August 09, 2017 @09:45AM (#14968694)
> 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?

Re:JavaScript for People Who Hate JavaScript by notsrg on Wednesday August 09, 2017 @03:37PM (#14972787)
Ughhhh... what?
Re:JavaScript for People Who Hate JavaScript by heavenlyblue on Thursday August 10, 2017 @05:31AM (#14977988)
It'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.